MCPcopy Create free account
hub / github.com/go-git/go-git / TestPushForceWithOption

Method TestPushForceWithOption

remote_test.go:861–887  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

859}
860
861func (s *RemoteSuite) TestPushForceWithOption(c *C) {
862 f := fixtures.Basic().One()
863 sto := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
864
865 dstFs := f.DotGit()
866 dstSto := filesystem.NewStorage(dstFs, cache.NewObjectLRUDefault())
867
868 url := dstFs.Root()
869 r := NewRemote(sto, &config.RemoteConfig{
870 Name: DefaultRemoteName,
871 URLs: []string{url},
872 })
873
874 oldRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
875 c.Assert(err, IsNil)
876 c.Assert(oldRef, NotNil)
877
878 err = r.Push(&PushOptions{
879 RefSpecs: []config.RefSpec{"refs/heads/master:refs/heads/branch"},
880 Force: true,
881 })
882 c.Assert(err, IsNil)
883
884 newRef, err := dstSto.Reference(plumbing.ReferenceName("refs/heads/branch"))
885 c.Assert(err, IsNil)
886 c.Assert(newRef, Not(DeepEquals), oldRef)
887}
888
889func (s *RemoteSuite) TestPushForceWithLease_success(c *C) {
890 testCases := []struct {

Callers

nothing calls this directly

Calls 7

PushMethod · 0.95
NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
ReferenceNameTypeAlias · 0.92
NewRemoteFunction · 0.85
RootMethod · 0.80
ReferenceMethod · 0.65

Tested by

no test coverage detected