mirror of
https://github.com/golang/go
synced 2024-11-18 22:34:45 -07:00
go/vcs: accept plain file for .vcs (instead of directory)
Sometimes .git is a plain file; maybe others will follow. Fixes golang/go#10322. Change-Id: Id57424998c207080c3ed5826b1e5e091fa26aad5 Reviewed-on: https://go-review.googlesource.com/21430 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a2b1312ca0
commit
b44548ae6a
@ -347,7 +347,7 @@ func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error) {
|
|||||||
origDir := dir
|
origDir := dir
|
||||||
for len(dir) > len(srcRoot) {
|
for len(dir) > len(srcRoot) {
|
||||||
for _, vcs := range vcsList {
|
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
|
return vcs, filepath.ToSlash(dir[len(srcRoot)+1:]), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,23 @@ func TestFromDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tempDir)
|
defer os.RemoveAll(tempDir)
|
||||||
|
|
||||||
for _, vcs := range vcsList {
|
for j, vcs := range vcsList {
|
||||||
dir := filepath.Join(tempDir, "example.com", vcs.Name, "."+vcs.Cmd)
|
dir := filepath.Join(tempDir, "example.com", vcs.Name, "."+vcs.Cmd)
|
||||||
err := os.MkdirAll(dir, 0755)
|
if j&1 == 0 {
|
||||||
if err != nil {
|
err := os.MkdirAll(dir, 0755)
|
||||||
t.Fatal(err)
|
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{
|
want := RepoRoot{
|
||||||
|
Loading…
Reference in New Issue
Block a user