aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorFedor Korotkov <fedor.korotkov@gmail.com>2018-08-08 09:09:12 -0400
committerFedor Korotkov <fedor.korotkov@gmail.com>2018-08-08 09:09:12 -0400
commit7b1248177ad3533c63590c7c47495f28f0f3da71 (patch)
treefd1664bfb917a5455cf64ad0db13d7b8add57ed5 /repository_test.go
parent43d17e14b714665ab5bc2ecc220b6740779d733f (diff)
downloadgo-git-7b1248177ad3533c63590c7c47495f28f0f3da71.tar.gz
Fixed cloning of a single tag
Relates to #870 Signed-off-by: Fedor Korotkov <fedor.korotkov@gmail.com>
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/repository_test.go b/repository_test.go
index b78fbb7..7580878 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -846,7 +846,33 @@ func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) {
objects, err := r.Objects()
c.Assert(err, IsNil)
objects.ForEach(func(object.Object) error { count++; return nil })
- c.Assert(count, Equals, 31)
+ c.Assert(count, Equals, 28)
+}
+
+func (s *RepositorySuite) TestCloneDetachedHEADAndSingle(c *C) {
+ r, _ := Init(memory.NewStorage(), nil)
+ err := r.clone(context.Background(), &CloneOptions{
+ URL: s.GetBasicLocalRepositoryURL(),
+ ReferenceName: plumbing.ReferenceName("refs/tags/v1.0.0"),
+ SingleBranch: true,
+ })
+ c.Assert(err, IsNil)
+
+ cfg, err := r.Config()
+ c.Assert(err, IsNil)
+ c.Assert(cfg.Branches, HasLen, 0)
+
+ head, err := r.Reference(plumbing.HEAD, false)
+ c.Assert(err, IsNil)
+ c.Assert(head, NotNil)
+ c.Assert(head.Type(), Equals, plumbing.HashReference)
+ c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+
+ count := 0
+ objects, err := r.Objects()
+ c.Assert(err, IsNil)
+ objects.ForEach(func(object.Object) error { count++; return nil })
+ c.Assert(count, Equals, 28)
}
func (s *RepositorySuite) TestCloneDetachedHEADAndShallow(c *C) {