]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: tests: rename git-min-vers->git-sha256
authorDavid Finkel <david.finkel@gmail.com>
Fri, 14 Nov 2025 01:43:11 +0000 (20:43 -0500)
committerMichael Matloob <matloob@google.com>
Fri, 14 Nov 2025 22:05:59 +0000 (14:05 -0800)
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 <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>
src/cmd/go/internal/vcweb/script.go
src/cmd/go/scriptconds_test.go
src/cmd/go/testdata/script/README
src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt
src/cmd/go/testdata/script/build_git_sha256_moddep.txt
src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt
src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt

index 0856c40677c1bc1fc48d9d30ffd1230e2c7cfe7a..8fa00b277503d7443eb6e1e6255b112bacb14859 100644 (file)
@@ -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")
+}
index c87c60ad33a31be5fb1873e746d01ffd6705c30d..4d7a9ac54bb663429e7d8a90f06379820d9b8450 100644 (file)
@@ -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 {
index d4f4c47af706f3b9cac9f16ae012215f1a81574a..2b5ab6948bdff1cb584da6528c97e8b3634a90d5 100644 (file)
@@ -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]
index 0773e08ea53e8a00240168ee2b8bc1128215ef40..1e71e25f11fede571bec52068dfdc10fff5ce5c6 100644 (file)
@@ -1,6 +1,6 @@
 [short] skip
 [!git] skip
-[!git-min-vers:v2.29] skip
+[!git-sha256] skip
 
 env GOPRIVATE=vcs-test.golang.org
 
index 21a296bd3d0845943832fd877b51da49e330ce13..7048e8f2e4b860df8a649b3a8c9d15c0104ea64f 100644 (file)
@@ -1,6 +1,6 @@
 [short] skip
 [!git] skip
-[!git-min-vers:v2.29] skip
+[!git-sha256] skip
 
 env GOPRIVATE=vcs-test.golang.org
 
index df772f5c4bbf82c29c2a9cd5ac3d5126a2b603f4..2f391e200e77fa303c564770e752c63e59b236c7 100644 (file)
@@ -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
 
index 15068a249ef4e5a68224550b3ec6c4cf1fab9c2e..a08e2949d3142a7e4ee93e512f1cebebcd796f6a 100644 (file)
@@ -1,4 +1,4 @@
-[!git-min-vers:v2.29] skip
+[!git-sha256] skip
 
 handle git