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

Method TestPushRejectNonFastForward

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

Source from the content-addressed store, hash-verified

802}
803
804func (s *RemoteSuite) TestPushRejectNonFastForward(c *C) {
805 fs := fixtures.Basic().One().DotGit()
806 server := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
807
808 url, clean := s.TemporalDir()
809 defer clean()
810
811 r, err := PlainClone(url, true, &CloneOptions{
812 URL: fs.Root(),
813 })
814 c.Assert(err, IsNil)
815
816 remote, err := r.Remote(DefaultRemoteName)
817 c.Assert(err, IsNil)
818
819 branch := plumbing.ReferenceName("refs/heads/branch")
820 oldRef, err := server.Reference(branch)
821 c.Assert(err, IsNil)
822 c.Assert(oldRef, NotNil)
823
824 err = remote.Push(&PushOptions{RefSpecs: []config.RefSpec{
825 "refs/heads/master:refs/heads/branch",
826 }})
827 c.Assert(err, ErrorMatches, "non-fast-forward update: refs/heads/branch")
828
829 newRef, err := server.Reference(branch)
830 c.Assert(err, IsNil)
831 c.Assert(newRef, DeepEquals, oldRef)
832}
833
834func (s *RemoteSuite) TestPushForce(c *C) {
835 f := fixtures.Basic().One()

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
ReferenceNameTypeAlias · 0.92
PlainCloneFunction · 0.85
TemporalDirMethod · 0.80
RootMethod · 0.80
RemoteMethod · 0.80
ReferenceMethod · 0.65
PushMethod · 0.65

Tested by

no test coverage detected