diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-05-03 10:46:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-03 10:46:39 +0100 |
commit | 02856b824a05c18118c116af5b0e2bca1b3496b3 (patch) | |
tree | 86f0f043a8176a790c132d2862f8f3f4565c398e /remote_test.go | |
parent | 0542a302c2be7ed7de276411f7e20b87309734b9 (diff) | |
parent | 19b39e150071832541f2cdcb669446a8609f57e7 (diff) | |
download | go-git-02856b824a05c18118c116af5b0e2bca1b3496b3.tar.gz |
Merge pull request #750 from pjbgf/peel
git: Add support to ls-remote with peeled references. Fixes #749
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go index 751c89a..164e4e5 100644 --- a/remote_test.go +++ b/remote_test.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "time" "github.com/go-git/go-git/v5/config" @@ -865,6 +866,7 @@ func (s *RemoteSuite) TestPushForceWithLease_success(c *C) { c.Assert(sto.SetReference(newCommit), IsNil) ref, err := sto.Reference("refs/heads/branch") + c.Assert(err, IsNil) c.Log(ref.String()) url := dstFs.Root() @@ -1210,6 +1212,41 @@ func (s *RemoteSuite) TestList(c *C) { } } +func (s *RemoteSuite) TestListPeeling(c *C) { + remote := NewRemote(memory.NewStorage(), &config.RemoteConfig{ + Name: DefaultRemoteName, + URLs: []string{"https://github.com/git-fixtures/tags.git"}, + }) + + for _, tc := range []struct { + peelingOption PeelingOption + expectPeeled bool + expectNonPeeled bool + }{ + {peelingOption: AppendPeeled, expectPeeled: true, expectNonPeeled: true}, + {peelingOption: IgnorePeeled, expectPeeled: false, expectNonPeeled: true}, + {peelingOption: OnlyPeeled, expectPeeled: true, expectNonPeeled: false}, + } { + refs, err := remote.List(&ListOptions{ + PeelingOption: tc.peelingOption, + }) + c.Assert(err, IsNil) + c.Assert(len(refs) > 0, Equals, true) + + foundPeeled, foundNonPeeled := false, false + for _, ref := range refs { + if strings.HasSuffix(ref.Name().String(), peeledSuffix) { + foundPeeled = true + } else { + foundNonPeeled = true + } + } + + c.Assert(foundPeeled, Equals, tc.expectPeeled) + c.Assert(foundNonPeeled, Equals, tc.expectNonPeeled) + } +} + func (s *RemoteSuite) TestListTimeout(c *C) { remote := NewRemote(memory.NewStorage(), &config.RemoteConfig{ Name: DefaultRemoteName, |