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

Method TestPullNonFastForward

worktree_test.go:107–142  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

105}
106
107func (s *WorktreeSuite) TestPullNonFastForward(c *C) {
108 url, clean := s.TemporalDir()
109 defer clean()
110
111 path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
112
113 server, err := PlainClone(url, false, &CloneOptions{
114 URL: path,
115 })
116 c.Assert(err, IsNil)
117
118 dir, clean := s.TemporalDir()
119 defer clean()
120
121 r, err := PlainClone(dir, false, &CloneOptions{
122 URL: url,
123 })
124 c.Assert(err, IsNil)
125
126 w, err := server.Worktree()
127 c.Assert(err, IsNil)
128 err = os.WriteFile(filepath.Join(path, "foo"), []byte("foo"), 0755)
129 c.Assert(err, IsNil)
130 _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()})
131 c.Assert(err, IsNil)
132
133 w, err = r.Worktree()
134 c.Assert(err, IsNil)
135 err = os.WriteFile(filepath.Join(path, "bar"), []byte("bar"), 0755)
136 c.Assert(err, IsNil)
137 _, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()})
138 c.Assert(err, IsNil)
139
140 err = w.Pull(&PullOptions{})
141 c.Assert(err, Equals, ErrNonFastForwardUpdate)
142}
143
144func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) {
145 r, _ := Init(memory.NewStorage(), memfs.New())

Callers

nothing calls this directly

Calls 8

PlainCloneFunction · 0.85
defaultSignatureFunction · 0.85
TemporalDirMethod · 0.80
RootMethod · 0.80
WorktreeMethod · 0.80
JoinMethod · 0.80
PullMethod · 0.80
CommitMethod · 0.65

Tested by

no test coverage detected