aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-04-04 18:46:26 +0200
committerGitHub <noreply@github.com>2018-04-04 18:46:26 +0200
commitc4ace4d53535d00899503bfaedc6e9709e3aff0a (patch)
tree2c27503469c0e5fb5ae6028819d20df673a2ab76 /repository_test.go
parent247cf690745dfd67ccd9f0c07878e6dd85e6c9ed (diff)
parent5e8e011f6537e6822350a16a243db5802d4151e6 (diff)
downloadgo-git-c4ace4d53535d00899503bfaedc6e9709e3aff0a.tar.gz
Merge pull request #784 from mvdan/open-detect
add PlainOpen variant to find .git in parent dirs
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(),