Skip to content

Commit

Permalink
cmd/go: report correct directory for 'no version control'
Browse files Browse the repository at this point in the history
The scan starts at the directory we care about and works
backward to the GOPATH root. The error should say the
original directory name, not the name of the GOPATH root.

Fixes #6175.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13366050
  • Loading branch information
rsc committed Sep 10, 2013
1 parent 6034406 commit b99fdb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/cmd/go/test.bash
Expand Up @@ -139,6 +139,18 @@ if ! ./testgo test ./testdata/testimport/*.go; then
ok=false
fi

TEST version control error message includes correct directory
export GOPATH=$(pwd)/testdata/shadow/root1
if ./testgo get -u foo 2>testdata/err; then
echo "go get -u foo succeeded unexpectedly"
ok=false
elif ! grep testdata/shadow/root1/src/foo testdata/err >/dev/null; then
echo "go get -u error does not mention shadow/root1/src/foo:"
cat testdata/err
ok=false
fi
unset GOPATH

# Test that without $GOBIN set, binaries get installed
# into the GOPATH bin directory.
TEST install into GOPATH
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/go/vcs.go
Expand Up @@ -321,6 +321,7 @@ func vcsForDir(p *Package) (vcs *vcsCmd, root string, err error) {
return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot)
}

origDir := dir
for len(dir) > len(srcRoot) {
for _, vcs := range vcsList {
if fi, err := os.Stat(filepath.Join(dir, "."+vcs.cmd)); err == nil && fi.IsDir() {
Expand All @@ -337,7 +338,7 @@ func vcsForDir(p *Package) (vcs *vcsCmd, root string, err error) {
dir = ndir
}

return nil, "", fmt.Errorf("directory %q is not using a known version control system", dir)
return nil, "", fmt.Errorf("directory %q is not using a known version control system", origDir)
}

// repoRoot represents a version control system, a repo, and a root of
Expand Down

0 comments on commit b99fdb2

Please sign in to comment.