mirror of
https://github.com/golang/go
synced 2024-11-18 10:24:42 -07:00
cmd/go: accept plain file for .vcs (instead of directory)
Sometimes .git is a plain file; maybe others will follow. This CL matches CL 21430, made in x/tools/go/vcs. The change in the Swift test case makes the test case pass by changing the test to match current behavior, which I assume is better than the reverse. (The test only runs locally and without -short, so the builders are not seeing this particular failure.) For #10322. Change-Id: Iccd08819a01c5609a2880b9d8a99af936e20faff Reviewed-on: https://go-review.googlesource.com/30948 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
d26b0661c2
commit
9a97c3bfe4
@ -500,7 +500,7 @@ func vcsFromDir(dir, srcRoot string) (vcs *vcsCmd, root string, err error) {
|
||||
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() {
|
||||
if _, err := os.Stat(filepath.Join(dir, "."+vcs.cmd)); err == nil {
|
||||
return vcs, filepath.ToSlash(dir[len(srcRoot)+1:]), nil
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func TestRepoRootForImportPath(t *testing.T) {
|
||||
"git.openstack.org/openstack/swift.git",
|
||||
&repoRoot{
|
||||
vcs: vcsGit,
|
||||
repo: "https://git.openstack.org/openstack/swift",
|
||||
repo: "https://git.openstack.org/openstack/swift.git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -174,12 +174,24 @@ func TestFromDir(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
for _, vcs := range vcsList {
|
||||
for j, vcs := range vcsList {
|
||||
dir := filepath.Join(tempDir, "example.com", vcs.name, "."+vcs.cmd)
|
||||
if j&1 == 0 {
|
||||
err := os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
err := os.MkdirAll(filepath.Dir(dir), 0755)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f, err := os.Create(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
|
||||
want := repoRoot{
|
||||
vcs: vcs,
|
||||
|
Loading…
Reference in New Issue
Block a user