diff options
author | Fedor Korotkov <fedor.korotkov@gmail.com> | 2018-11-07 08:43:24 -0500 |
---|---|---|
committer | Fedor Korotkov <fedor.korotkov@gmail.com> | 2018-11-07 08:43:24 -0500 |
commit | 3ab4ee58fe422467be6f7a9257775685a7192e03 (patch) | |
tree | 14e569f6a3b01756786f77a242d82a06328353b9 /repository_test.go | |
parent | 959dc01faa3352c0b41ff0fa257239f5f00165db (diff) | |
download | go-git-3ab4ee58fe422467be6f7a9257775685a7192e03.tar.gz |
repository: Fix RefSpec for a single tag. Fixes #960
Signed-off-by: Fedor Korotkov <fedor.korotkov@gmail.com>
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go index ba2cf1a..59ab89e 100644 --- a/repository_test.go +++ b/repository_test.go @@ -919,6 +919,32 @@ func (s *RepositorySuite) TestCloneSingleBranch(c *C) { c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") } +func (s *RepositorySuite) TestCloneSingleTag(c *C) { + r, _ := Init(memory.NewStorage(), nil) + + url := s.GetLocalRepositoryURL( + fixtures.ByURL("https://github.com/git-fixtures/tags.git").One(), + ) + + err := r.clone(context.Background(), &CloneOptions{ + URL: url, + SingleBranch: true, + ReferenceName: plumbing.ReferenceName("refs/tags/commit-tag"), + }) + c.Assert(err, IsNil) + + branch, err := r.Reference("refs/tags/commit-tag", false) + c.Assert(err, IsNil) + c.Assert(branch, NotNil) + + conf, err := r.Config() + c.Assert(err, IsNil) + originRemote := conf.Remotes["origin"] + c.Assert(originRemote, NotNil) + c.Assert(originRemote.Fetch, HasLen, 1) + c.Assert(originRemote.Fetch[0].String(), Equals, "+refs/tags/commit-tag:refs/tags/commit-tag") +} + func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) { r, _ := Init(memory.NewStorage(), nil) err := r.clone(context.Background(), &CloneOptions{ |