diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2019-07-26 18:59:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-26 18:59:37 +0200 |
commit | 1edb992dbc419a0767b1cf3a524b0d35529799f5 (patch) | |
tree | fe994302589318133ec34e74bfe8c8f302a5147d /remote_test.go | |
parent | 4a6d836e2fa35fd05d2bfeeaecbb546c2e10ece1 (diff) | |
parent | 17ea92a0703c21b744560e6586ee61431dba9ffb (diff) | |
download | go-git-1edb992dbc419a0767b1cf3a524b0d35529799f5.tar.gz |
Merge pull request #1165 from seletskiy/push-prune
Remote: add Prune option to PushOptions
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/remote_test.go b/remote_test.go index 70a14e9..a45d814 100644 --- a/remote_test.go +++ b/remote_test.go @@ -21,7 +21,7 @@ import ( . "gopkg.in/check.v1" "gopkg.in/src-d/go-billy.v4/osfs" - "gopkg.in/src-d/go-git-fixtures.v3" + fixtures "gopkg.in/src-d/go-git-fixtures.v3" ) type RemoteSuite struct { @@ -583,6 +583,63 @@ func (s *RemoteSuite) TestPushForce(c *C) { c.Assert(newRef, Not(DeepEquals), oldRef) } +func (s *RemoteSuite) TestPushPrune(c *C) { + fs := fixtures.Basic().One().DotGit() + url := c.MkDir() + server, err := PlainClone(url, true, &CloneOptions{ + URL: fs.Root(), + }) + c.Assert(err, IsNil) + + r, err := PlainClone(c.MkDir(), true, &CloneOptions{ + URL: url, + }) + c.Assert(err, IsNil) + + tag, err := r.Reference(plumbing.ReferenceName("refs/tags/v1.0.0"), true) + c.Assert(err, IsNil) + + err = r.DeleteTag("v1.0.0") + c.Assert(err, IsNil) + + remote, err := r.Remote(DefaultRemoteName) + c.Assert(err, IsNil) + + ref, err := r.Reference(plumbing.ReferenceName("refs/heads/master"), true) + c.Assert(err, IsNil) + + err = remote.Push(&PushOptions{ + RefSpecs: []config.RefSpec{ + config.RefSpec("refs/heads/*:refs/heads/*"), + }, + Prune: true, + }) + c.Assert(err, Equals, NoErrAlreadyUpToDate) + + AssertReferences(c, server, map[string]string{ + "refs/tags/v1.0.0": tag.Hash().String(), + }) + + err = remote.Push(&PushOptions{ + RefSpecs: []config.RefSpec{ + config.RefSpec("*:*"), + }, + Prune: true, + }) + c.Assert(err, IsNil) + + AssertReferences(c, server, map[string]string{ + "refs/remotes/origin/master": ref.Hash().String(), + }) + + AssertReferences(c, server, map[string]string{ + "refs/remotes/origin/master": ref.Hash().String(), + }) + + ref, err = server.Reference(plumbing.ReferenceName("refs/tags/v1.0.0"), true) + c.Assert(err, Equals, plumbing.ErrReferenceNotFound) +} + func (s *RemoteSuite) TestPushNewReference(c *C) { fs := fixtures.Basic().One().DotGit() url := c.MkDir() |