aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
authorkappyhappy <t.katsu1031@gmail.com>2020-05-21 10:36:31 +0900
committerkappyhappy <t.katsu1031@gmail.com>2020-05-21 18:12:48 +0900
commitb5b511a94e28ea0346fc83a2afec43e5514fdb1e (patch)
tree300780aa8d799bef9ac7c85618e514f07bb72516 /remote_test.go
parent838eb2979f6085fc0e5bc8856e7f1944a455a970 (diff)
downloadgo-git-b5b511a94e28ea0346fc83a2afec43e5514fdb1e.tar.gz
Remote.Push: support force option
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index 0fc3449..ce46390 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -612,6 +612,34 @@ func (s *RemoteSuite) TestPushForce(c *C) {
c.Assert(newRef, Not(DeepEquals), oldRef)
}
+func (s *RemoteSuite) TestPushForceWithOption(c *C) {
+ f := fixtures.Basic().One()
+ sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
+
+ dstFs := f.DotGit()
+ dstSto := filesystem.NewStorage(dstFs, cache.NewObjectLRUDefault())
+
+ url := dstFs.Root()
+ r := NewRemote(sto, &config.RemoteConfig{
+ Name: DefaultRemoteName,
+ URLs: []string{url},
+ })
+
+ oldRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
+ c.Assert(err, IsNil)
+ c.Assert(oldRef, NotNil)
+
+ err = r.Push(&PushOptions{
+ RefSpecs: []config.RefSpec{"refs/heads/master:refs/heads/branch"},
+ Force: true,
+ })
+ c.Assert(err, IsNil)
+
+ newRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
+ c.Assert(err, IsNil)
+ c.Assert(newRef, Not(DeepEquals), oldRef)
+}
+
func (s *RemoteSuite) TestPushPrune(c *C) {
fs := fixtures.Basic().One().DotGit()
url := c.MkDir()