aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2018-03-14 16:32:48 +0000
committerDaniel Martí <mvdan@mvdan.cc>2018-04-03 16:14:07 +0100
commit5e8e011f6537e6822350a16a243db5802d4151e6 (patch)
tree2c27503469c0e5fb5ae6028819d20df673a2ab76 /repository_test.go
parent247cf690745dfd67ccd9f0c07878e6dd85e6c9ed (diff)
downloadgo-git-5e8e011f6537e6822350a16a243db5802d4151e6.tar.gz
add PlainOpen variant to find .git in parent dirs
This is the git tool's behavior that people are used to; if one runs a git command in a repository's subdirectory, git still works. Fixes #765. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index f39f358..4765a53 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -407,6 +407,36 @@ func (s *RepositorySuite) TestPlainOpenNotExists(c *C) {
c.Assert(r, IsNil)
}
+func (s *RepositorySuite) TestPlainOpenDetectDotGit(c *C) {
+ dir, err := ioutil.TempDir("", "plain-open")
+ c.Assert(err, IsNil)
+ defer os.RemoveAll(dir)
+
+ subdir := filepath.Join(dir, "a", "b")
+ err = os.MkdirAll(subdir, 0755)
+ c.Assert(err, IsNil)
+
+ r, err := PlainInit(dir, false)
+ c.Assert(err, IsNil)
+ c.Assert(r, NotNil)
+
+ opt := &PlainOpenOptions{DetectDotGit: true}
+ r, err = PlainOpenWithOptions(subdir, opt)
+ c.Assert(err, IsNil)
+ c.Assert(r, NotNil)
+}
+
+func (s *RepositorySuite) TestPlainOpenNotExistsDetectDotGit(c *C) {
+ dir, err := ioutil.TempDir("", "plain-open")
+ c.Assert(err, IsNil)
+ defer os.RemoveAll(dir)
+
+ opt := &PlainOpenOptions{DetectDotGit: true}
+ r, err := PlainOpenWithOptions(dir, opt)
+ c.Assert(err, Equals, ErrRepositoryNotExists)
+ c.Assert(r, IsNil)
+}
+
func (s *RepositorySuite) TestPlainClone(c *C) {
r, err := PlainClone(c.MkDir(), false, &CloneOptions{
URL: s.GetBasicLocalRepositoryURL(),