diff --git a/main.go b/main.go index 9874234..b563d59 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,6 @@ import ( "unicode/utf8" "github.com/rogpeppe/go-internal/cache" - "golang.org/x/mod/module" "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/go/ssa" "mvdan.cc/garble/internal/ctrlflow" @@ -371,38 +370,6 @@ func mainErr(args []string) error { mod = mod.Replace } - // For the tests. - if v := os.Getenv("GARBLE_TEST_BUILDSETTINGS"); v != "" { - var extra []debug.BuildSetting - if err := json.Unmarshal([]byte(v), &extra); err != nil { - return err - } - info.Settings = append(info.Settings, extra...) - } - - // Until https://github.com/golang/go/issues/50603 is implemented, - // manually construct something like a pseudo-version. - // TODO: remove when this code is dead, hopefully in Go 1.22. - if mod.Version == "(devel)" { - var vcsTime time.Time - var vcsRevision string - for _, setting := range info.Settings { - switch setting.Key { - case "vcs.time": - // If the format is invalid, we'll print a zero timestamp. - vcsTime, _ = time.Parse(time.RFC3339Nano, setting.Value) - case "vcs.revision": - vcsRevision = setting.Value - if len(vcsRevision) > 12 { - vcsRevision = vcsRevision[:12] - } - } - } - if vcsRevision != "" { - mod.Version = module.PseudoVersion("", "", vcsTime, vcsRevision) - } - } - fmt.Printf("%s %s\n\n", mod.Path, mod.Version) fmt.Printf("Build settings:\n") for _, setting := range info.Settings { diff --git a/testdata/script/help.txtar b/testdata/script/help.txtar index 22b6b3e..8e4eb39 100644 --- a/testdata/script/help.txtar +++ b/testdata/script/help.txtar @@ -87,26 +87,12 @@ stderr 'directory not found' # Test the version command. Note that test binaries exclude VCS build info, # and we reuse the test binary for garble itself, so that's missing. -# To avoid building another garble binary, -# and to be able to use static VCS info, use an environment variable. -# First, test without the information, and then with it. exec garble version stdout -count=1 'mvdan.cc/garble \(devel\)' stdout -count=1 'Build settings' stdout -count=3 '-compiler|GOOS|GOARCH' ! stdout 'vcs' -# Obtained from a real build while developing. -env GARBLE_TEST_BUILDSETTINGS='[{"Key":"vcs","Value":"git"},{"Key":"vcs.revision","Value":"91ea246349544769f5100c29f79cb0f173abfeea"},{"Key":"vcs.time","Value":"2022-03-18T13:45:11Z"},{"Key":"vcs.modified","Value":"true"}]' -exec garble version -stdout -count=1 'mvdan\.cc/garble v0\.0\.0-20220318134511-91ea24634954' -stdout -count=1 'Build settings' -stdout -count=3 '-compiler|GOOS|GOARCH' -stdout -count=1 'vcs git' -stdout -count=1 'vcs\.revision 91ea246349544769f5100c29f79cb0f173abfeea' -stdout -count=1 'vcs\.time 2022-03-18T13:45:11Z' -stdout -count=1 'vcs\.modified true' - ! exec garble version -flag stderr 'usage: garble version'