diff options
author | Stanislav Seletskiy <s.seletskiy@gmail.com> | 2019-06-11 02:33:09 +0300 |
---|---|---|
committer | Stanislav Seletskiy <s.seletskiy@gmail.com> | 2019-07-25 16:38:47 +0300 |
commit | 5d9007f27b50c17cefecd13ad160840aa4f86ed1 (patch) | |
tree | 0c5eb99b444e361a2380b2083f066860cf55212c /remote_test.go | |
parent | 60033b8925a18fff9f68bea3d980076f73eb3cb5 (diff) | |
download | go-git-5d9007f27b50c17cefecd13ad160840aa4f86ed1.tar.gz |
add Prune option to PushOptions
Signed-off-by: Stanislav Seletskiy <s.seletskiy@gmail.com>
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 58a0598..290b574 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() |