MCPcopy
hub / github.com/go-git/go-git / TestPullNonFastForward

Method TestPullNonFastForward

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

Source from the content-addressed store, hash-verified

107}
108
109func (s *WorktreeSuite) TestPullNonFastForward(c *C) {
110 url := c.MkDir()
111
112 path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
113
114 server, err := PlainClone(url, false, &CloneOptions{
115 URL: path,
116 })
117 c.Assert(err, IsNil)
118
119 dir := c.MkDir()
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(url, "foo"), []byte("foo"), 0755)
129 c.Assert(err, IsNil)
130 w.Add("foo")
131 _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()})
132 c.Assert(err, IsNil)
133
134 w, err = r.Worktree()
135 c.Assert(err, IsNil)
136 err = os.WriteFile(filepath.Join(dir, "bar"), []byte("bar"), 0755)
137 c.Assert(err, IsNil)
138 w.Add("bar")
139 _, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()})
140 c.Assert(err, IsNil)
141
142 err = w.Pull(&PullOptions{})
143 c.Assert(err, Equals, ErrNonFastForwardUpdate)
144}
145
146func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) {
147 r, _ := Init(memory.NewStorage(), memfs.New())

Callers

nothing calls this directly

Calls 8

PlainCloneFunction · 0.85
defaultSignatureFunction · 0.85
RootMethod · 0.80
WorktreeMethod · 0.80
JoinMethod · 0.80
PullMethod · 0.80
CommitMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected