aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Finkel <david.finkel@gmail.com>2025-11-13 20:43:11 -0500
committerGopher Robot <gobot@golang.org>2026-03-26 09:05:42 -0700
commitcff64a5cf3f072a7f5d543e16bd0f9f1801bdffd (patch)
tree2e3afffe82d639c78716e0ade790d7dc07b2382e
parent7301bd39d1e17a6b24b334b1b6e276e590c4c6c5 (diff)
downloadgo-cff64a5cf3f072a7f5d543e16bd0f9f1801bdffd.tar.xz
[release-branch.go1.25] 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-purposeful git-sha256 verb in the cmd tests. For #73704. Fixes #78384. Change-Id: I4361356431d567a6a3bb3a50eadfaa9e3ba37d90 Cq-Include-Trybots: luci.golang.try:go1.25-linux-amd64-longtest-git2.24.0 Reviewed-on: https://go-review.googlesource.com/c/go/+/720481 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> (cherry picked from commit c3708350a417a3149bf9191878c3ad945063d439) Reviewed-on: https://go-review.googlesource.com/c/go/+/759341 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
-rw-r--r--src/cmd/go/internal/vcweb/script.go8
-rw-r--r--src/cmd/go/scriptconds_test.go8
-rw-r--r--src/cmd/go/testdata/script/README4
-rw-r--r--src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt2
-rw-r--r--src/cmd/go/testdata/script/build_git_sha256_moddep.txt2
-rw-r--r--src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt2
-rw-r--r--src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt2
7 files changed, 18 insertions, 10 deletions
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("<suffix> 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 = <suffix> (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("<suffix> 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 <suffix>", 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:*]
- <suffix> 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