From: David Finkel Date: Fri, 14 Nov 2025 01:43:11 +0000 (-0500) Subject: cmd/go: tests: rename git-min-vers->git-sha256 X-Git-Tag: go1.26rc1~270 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c3708350a417a3149bf9191878c3ad945063d439;p=gostls13.git cmd/go: tests: rename git-min-vers->git-sha256 Follow-up cleanup on go.dev/cl/698835. Clarify the tests by replacing git-min-vers with a more-puposeful git-sha256 verb in the cmd tests. Updates: #73704 Change-Id: I4361356431d567a6a3bb3a50eadfaa9e3ba37d90 Reviewed-on: https://go-review.googlesource.com/c/go/+/720481 LUCI-TryBot-Result: Go LUCI Reviewed-by: Junyang Shao Reviewed-by: Michael Matloob Reviewed-by: Michael Matloob --- diff --git a/src/cmd/go/internal/vcweb/script.go b/src/cmd/go/internal/vcweb/script.go index 0856c40677..8fa00b2775 100644 --- a/src/cmd/go/internal/vcweb/script.go +++ b/src/cmd/go/internal/vcweb/script.go @@ -44,7 +44,7 @@ func newScriptEngine() *script.Engine { return script.OnceCondition(summary, func() (bool, error) { return f(), nil }) } add("bzr", lazyBool("the 'bzr' executable exists and provides the standard CLI", hasWorkingBzr)) - add("git-min-vers", script.PrefixCondition(" indicates a minimum git version", hasAtLeastGitVersion)) + add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256)) interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) } gracePeriod := 30 * time.Second // arbitrary @@ -412,10 +412,14 @@ func gitVersion() (string, error) { return "v" + string(matches[1]), nil } -func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) { +func hasAtLeastGitVersion(minVers string) (bool, error) { gitVers, gitVersErr := gitVersion() if gitVersErr != nil { return false, gitVersErr } return semver.Compare(minVers, gitVers) <= 0, nil } + +func gitSupportsSHA256() (bool, error) { + return hasAtLeastGitVersion("v2.29") +} diff --git a/src/cmd/go/scriptconds_test.go b/src/cmd/go/scriptconds_test.go index c87c60ad33..4d7a9ac54b 100644 --- a/src/cmd/go/scriptconds_test.go +++ b/src/cmd/go/scriptconds_test.go @@ -44,7 +44,7 @@ func scriptConditions(t *testing.T) map[string]script.Cond { add("case-sensitive", script.OnceCondition("$WORK filesystem is case-sensitive", isCaseSensitive)) add("cc", script.PrefixCondition("go env CC = (ignoring the go/env file)", ccIs)) add("git", lazyBool("the 'git' executable exists and provides the standard CLI", hasWorkingGit)) - add("git-min-vers", script.PrefixCondition(" indicates a minimum git version", hasAtLeastGitVersion)) + add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256)) add("net", script.PrefixCondition("can connect to external network host ", hasNet)) add("trimpath", script.OnceCondition("test binary was built with -trimpath", isTrimpath)) @@ -171,7 +171,7 @@ func gitVersion() (string, error) { return "v" + string(matches[1]), nil } -func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) { +func hasAtLeastGitVersion(minVers string) (bool, error) { gitVers, gitVersErr := gitVersion() if gitVersErr != nil { return false, gitVersErr @@ -179,6 +179,10 @@ func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) { return semver.Compare(minVers, gitVers) <= 0, nil } +func gitSupportsSHA256() (bool, error) { + return hasAtLeastGitVersion("v2.29") +} + func hasWorkingBzr() bool { bzr, err := exec.LookPath("bzr") if err != nil { diff --git a/src/cmd/go/testdata/script/README b/src/cmd/go/testdata/script/README index d4f4c47af7..2b5ab6948b 100644 --- a/src/cmd/go/testdata/script/README +++ b/src/cmd/go/testdata/script/README @@ -399,8 +399,8 @@ The available conditions are: GOOS/GOARCH supports -fuzz with instrumentation [git] the 'git' executable exists and provides the standard CLI -[git-min-vers:*] - indicates a minimum git version +[git-sha256] + the local 'git' version is recent enough to support sha256 object/commit hashes [go-builder] GO_BUILDER_NAME is non-empty [link] diff --git a/src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt b/src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt index 0773e08ea5..1e71e25f11 100644 --- a/src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt +++ b/src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt @@ -1,6 +1,6 @@ [short] skip [!git] skip -[!git-min-vers:v2.29] skip +[!git-sha256] skip env GOPRIVATE=vcs-test.golang.org diff --git a/src/cmd/go/testdata/script/build_git_sha256_moddep.txt b/src/cmd/go/testdata/script/build_git_sha256_moddep.txt index 21a296bd3d..7048e8f2e4 100644 --- a/src/cmd/go/testdata/script/build_git_sha256_moddep.txt +++ b/src/cmd/go/testdata/script/build_git_sha256_moddep.txt @@ -1,6 +1,6 @@ [short] skip [!git] skip -[!git-min-vers:v2.29] skip +[!git-sha256] skip env GOPRIVATE=vcs-test.golang.org diff --git a/src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt b/src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt index df772f5c4b..2f391e200e 100644 --- a/src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt +++ b/src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt @@ -1,6 +1,6 @@ [short] skip [!git] skip -[!git-min-vers:v2.29] skip +[!git-sha256] skip # This is a git sha256-mode copy of mod_download_git_bareRepository diff --git a/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt b/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt index 15068a249e..a08e2949d3 100644 --- a/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt +++ b/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt @@ -1,4 +1,4 @@ -[!git-min-vers:v2.29] skip +[!git-sha256] skip handle git