diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-05-21 12:31:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 12:31:46 +0200 |
commit | 6d8103df45ce09ffd5323b4ef46d26440400a54f (patch) | |
tree | 300780aa8d799bef9ac7c85618e514f07bb72516 /remote_test.go | |
parent | 838eb2979f6085fc0e5bc8856e7f1944a455a970 (diff) | |
parent | b5b511a94e28ea0346fc83a2afec43e5514fdb1e (diff) | |
download | go-git-6d8103df45ce09ffd5323b4ef46d26440400a54f.tar.gz |
Merge pull request #71 from kappyhappy/master
Remote.Push: support force option
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 28 |
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() |