diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-26 16:19:06 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-26 16:19:06 +0200 |
commit | b0f131a48cd4e72d641fcfb3c73fd6eeddafb931 (patch) | |
tree | a9ebfdfb6b8316773145c7727af3a92a9847d72d /worktree_test.go | |
parent | e19163e22eb19b352dd022f6edc9d81e1cd7a7ed (diff) | |
download | go-git-b0f131a48cd4e72d641fcfb3c73fd6eeddafb931.tar.gz |
remote: pull refactor to match default behaviour
Diffstat (limited to 'worktree_test.go')
-rw-r--r-- | worktree_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 150176f..c565e29 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -51,6 +51,66 @@ func (s *WorktreeSuite) TestPullCheckout(c *C) { c.Assert(fi, HasLen, 8) } +func (s *WorktreeSuite) TestPullFastForward(c *C) { + url := c.MkDir() + path := fixtures.Basic().ByTag("worktree").One().Worktree().Root() + + server, err := PlainClone(url, false, &CloneOptions{ + URL: path, + }) + + r, err := PlainClone(c.MkDir(), false, &CloneOptions{ + URL: url, + }) + + w, err := server.Worktree() + c.Assert(err, IsNil) + err = ioutil.WriteFile(filepath.Join(path, "foo"), []byte("foo"), 0755) + c.Assert(err, IsNil) + hash, err := w.Commit("foo", &CommitOptions{Author: defaultSignature()}) + c.Assert(err, IsNil) + + w, err = r.Worktree() + c.Assert(err, IsNil) + + err = w.Pull(&PullOptions{}) + c.Assert(err, IsNil) + + head, err := r.Head() + c.Assert(err, IsNil) + c.Assert(head.Hash(), Equals, hash) +} + +func (s *WorktreeSuite) TestPullNonFastForward(c *C) { + url := c.MkDir() + path := fixtures.Basic().ByTag("worktree").One().Worktree().Root() + + server, err := PlainClone(url, false, &CloneOptions{ + URL: path, + }) + + r, err := PlainClone(c.MkDir(), false, &CloneOptions{ + URL: url, + }) + + w, err := server.Worktree() + c.Assert(err, IsNil) + err = ioutil.WriteFile(filepath.Join(path, "foo"), []byte("foo"), 0755) + c.Assert(err, IsNil) + _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()}) + c.Assert(err, IsNil) + + w, err = r.Worktree() + c.Assert(err, IsNil) + err = ioutil.WriteFile(filepath.Join(path, "bar"), []byte("bar"), 0755) + c.Assert(err, IsNil) + _, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()}) + c.Assert(err, IsNil) + + err = w.Pull(&PullOptions{}) + c.Assert(err, ErrorMatches, "non-fast-forward update") +} + func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) { r, _ := Init(memory.NewStorage(), memfs.New()) r.CreateRemote(&config.RemoteConfig{ |