aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorChris Gavin <chris@chrisgavin.me>2020-08-28 10:32:28 +0100
committerChris Gavin <chris@chrisgavin.me>2020-08-28 10:35:37 +0100
commit711b703b572e07d3d0437eae4662419b5c392a6b (patch)
treec0eec2aae09993118c120fa04db57bf1bd1126f9 /remote_test.go
parent5bf939bc5c03b149e7ec80653bcaa901d05d0d44 (diff)
downloadgo-git-711b703b572e07d3d0437eae4662419b5c392a6b.tar.gz
git: remote, Fix deleting references when force pushing.
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index ce46390..c6ea9ea 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -558,6 +558,31 @@ func (s *RemoteSuite) TestPushDeleteReference(c *C) {
c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
}
+func (s *RemoteSuite) TestForcePushDeleteReference(c *C) {
+ fs := fixtures.Basic().One().DotGit()
+ sto := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
+
+ r, err := PlainClone(c.MkDir(), true, &CloneOptions{
+ URL: fs.Root(),
+ })
+ c.Assert(err, IsNil)
+
+ remote, err := r.Remote(DefaultRemoteName)
+ c.Assert(err, IsNil)
+
+ err = remote.Push(&PushOptions{
+ RefSpecs: []config.RefSpec{":refs/heads/branch"},
+ Force: true,
+ })
+ c.Assert(err, IsNil)
+
+ _, err = sto.Reference(plumbing.ReferenceName("refs/heads/branch"))
+ c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
+
+ _, err = r.Storer.Reference(plumbing.ReferenceName("refs/heads/branch"))
+ c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
+}
+
func (s *RemoteSuite) TestPushRejectNonFastForward(c *C) {
fs := fixtures.Basic().One().DotGit()
server := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())