1
0
mirror of https://github.com/golang/go synced 2024-11-19 21:04:43 -07:00

Revert "cmd/dist: improve isGitRepo to handle git "worktree"s"

This reverts commit ab096d587f.

Change-Id: Icf366aa43acc41b4f8474edae0297e554368bf14
Reviewed-on: https://go-review.googlesource.com/18321
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Russ Cox 2016-01-06 17:39:34 +00:00
parent 7f0b4a879b
commit 91ba9f45c2

18
src/cmd/dist/build.go vendored
View File

@ -322,12 +322,18 @@ func findgoversion() string {
// isGitRepo reports whether the working directory is inside a Git repository.
func isGitRepo() bool {
// NB: simply checking the exit code of `git rev-parse --git-dir` would
// suffice here, but that requires deviating from the infrastructure
// provided by `run`.
gitDir := chomp(run(goroot, 0, "git", "rev-parse", "--git-dir"))
fi, err := os.Stat(gitDir)
return err == nil && fi.IsDir()
p := ".git"
for {
fi, err := os.Stat(p)
if os.IsNotExist(err) {
p = filepath.Join("..", p)
continue
}
if err != nil || !fi.IsDir() {
return false
}
return true
}
}
/*