Skip to content

Commit ec6af18

Browse files
committed
cmd/dist: add GOBOOTSTRAP_BUILDVCS environment variable
Add an environment variable to bypass the isGitRepo() check and force it to return false, thereby also setting -buildvcs=false during "go install." This is useful in situations where the .git directory may be present but we still want to force cmd/dist to ignore it. Fixes: #61620 Related: #54852
1 parent 7d0fce5 commit ec6af18

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/cmd/dist/build.go

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"path/filepath"
1818
"regexp"
1919
"sort"
20+
"strconv"
2021
"strings"
2122
"sync"
2223
"time"
@@ -435,6 +436,12 @@ func findgoversion() string {
435436

436437
// isGitRepo reports whether the working directory is inside a Git repository.
437438
func isGitRepo() bool {
439+
// Respect GOBOOTSTRAP_BUILDVCS=false if set to 0 or false.
440+
// Otherwise check if the Git repo is present with "git rev-parse" as usual.
441+
if val, err := strconv.ParseBool(os.Getenv("GOBOOTSTRAP_BUILDVCS")); err == nil && val == false {
442+
return false
443+
}
444+
438445
// NB: simply checking the exit code of `git rev-parse --git-dir` would
439446
// suffice here, but that requires deviating from the infrastructure
440447
// provided by `run`.

0 commit comments

Comments
 (0)