aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-26 16:19:06 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-26 16:19:06 +0200
commitb0f131a48cd4e72d641fcfb3c73fd6eeddafb931 (patch)
treea9ebfdfb6b8316773145c7727af3a92a9847d72d /worktree_test.go
parente19163e22eb19b352dd022f6edc9d81e1cd7a7ed (diff)
downloadgo-git-b0f131a48cd4e72d641fcfb3c73fd6eeddafb931.tar.gz
remote: pull refactor to match default behaviour
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go60
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{