-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto infer module when bud create
outside $GOPATH
#242
Conversation
@matthewmueller should I rename my branch? Line 253 in e23cd48
|
internal/cli/create/create.go
Outdated
For example, | ||
bud create --module=github.com/my/app %s | ||
`, c.Dir)) | ||
module.Name = "changeme" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make it change.me
because changeme
isn't a valid module name. This doesn't appear to have any ramifications right now, but I don't see a big deal with generating a valid name. See below for an example:
package main
import (
"fmt"
"os"
"golang.org/x/mod/module"
)
func main() {
if len(os.Args) <= 1 {
fmt.Println("no args")
return
}
modulePath := os.Args[1]
err := module.CheckPath(modulePath)
if err != nil {
fmt.Printf("invalid path %s: %s\n", modulePath, err)
os.Exit(1)
}
fmt.Printf("valid path %s\n", modulePath)
}
internal/cli/create/create_test.go
Outdated
is.Equal(result.Stdout(), "") | ||
is.Equal(result.Stderr(), "") | ||
is.NoErr(td.NotExists(".gitignore")) | ||
is.Equal(fileFirstLine(dir+"/go.mod"), "module changeme\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filepath.Join(dir, "go.mod")
internal/cli/create/create_test.go
Outdated
@@ -37,6 +50,7 @@ func TestCreateOutsideGoPathModulePath(t *testing.T) { | |||
is.NoErr(err) | |||
is.Equal(result.Stdout(), "") | |||
is.Equal(result.Stderr(), "") | |||
is.Equal(fileFirstLine(dir+"/go.mod"), "module github.com/my/app\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Thanks for working on this @012e! Just reviewed.
This looks like a bug in the recent Makefile E2E test not accounting for branches outside of I think the problem is that Could you try changing the Makefile and seeing if you can get So maybe something like the following: BRANCH_NAME ?= $(or $(GITHUB_HEAD_REF),main)
+ GITHUB_REPO ?= $(or $(GITHUB_REPOSITORY),livebud/bud)
GOPATH := $(shell go env GOPATH)
e2e: e2e.bud.build
e2e.bud.build:
- GOPRIVATE=github.com/livebud/bud go install github.com/livebud/bud@$(BRANCH_NAME)
+ GOPRIVATE=github.com/$(GITHUB_REPO) go install github.com/$(GITHUB_REPO)@$(BRANCH_NAME)
git clone https://github.com/livebud/welcome
( cd welcome && \
npm install && \
go mod tidy && \
- GOPRIVATE=github.com/livebud/bud go get github.com/livebud/bud@$(BRANCH_NAME) \
+ GOPRIVATE=github.com/$(GITHUB_REPO) go get github.com/$(GITHUB_REPO)@$(BRANCH_NAME) \
)
$(GOPATH)/bin/bud -C welcome build
./welcome/bud/app -h |
After a while researching, I found we can't |
Thanks @012e for the research! I just updated the e2e target to hopefully address this. Re-running tests. |
Cheers, thanks Huy! |
…ATH (#242) * auto infer module outside GOPATH * fix create test * default module name to `change.me`
Implements #240