aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-27 09:25:48 +0200
committerGitHub <noreply@github.com>2017-07-27 09:25:48 +0200
commit6b8d9f6d6bcf7f4282e5e4d7133f357d15ddc074 (patch)
treea9ebfdfb6b8316773145c7727af3a92a9847d72d /worktree_test.go
parente19163e22eb19b352dd022f6edc9d81e1cd7a7ed (diff)
parentb0f131a48cd4e72d641fcfb3c73fd6eeddafb931 (diff)
downloadgo-git-6b8d9f6d6bcf7f4282e5e4d7133f357d15ddc074.tar.gz
Merge pull request #511 from mcuadros/pull-ff
remote: pull refactor to match default behavior of cgit
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{