aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-02-08 10:02:03 +0100
committerGitHub <noreply@github.com>2019-02-08 10:02:03 +0100
commitdcc9f375f4daedfef61e7ff2fbbfd851d42a72d8 (patch)
tree494c22eb8c3b678e2f926614ef7d54fa46cbf663
parent00629a1f26e668d0da503455e2a61d7107da3160 (diff)
parentcf6cf0d4b77386acbc4b742ab2cb471b2206f5ae (diff)
downloadgo-git-dcc9f375f4daedfef61e7ff2fbbfd851d42a72d8.tar.gz
Merge pull request #1064 from asv/sentinel_error_for_no_ff_update
worktree: add sentinel error for non-fast-forward pull
-rw-r--r--worktree.go11
-rw-r--r--worktree_test.go2
2 files changed, 7 insertions, 6 deletions
diff --git a/worktree.go b/worktree.go
index e45d815..a14fd8d 100644
--- a/worktree.go
+++ b/worktree.go
@@ -25,10 +25,11 @@ import (
)
var (
- ErrWorktreeNotClean = errors.New("worktree is not clean")
- ErrSubmoduleNotFound = errors.New("submodule not found")
- ErrUnstagedChanges = errors.New("worktree contains unstaged changes")
- ErrGitModulesSymlink = errors.New(gitmodulesFile + " is a symlink")
+ ErrWorktreeNotClean = errors.New("worktree is not clean")
+ ErrSubmoduleNotFound = errors.New("submodule not found")
+ ErrUnstagedChanges = errors.New("worktree contains unstaged changes")
+ ErrGitModulesSymlink = errors.New(gitmodulesFile + " is a symlink")
+ ErrNonFastForwardUpdate = errors.New("non-fast-forward update")
)
// Worktree represents a git worktree.
@@ -101,7 +102,7 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error {
}
if !ff {
- return fmt.Errorf("non-fast-forward update")
+ return ErrNonFastForwardUpdate
}
}
diff --git a/worktree_test.go b/worktree_test.go
index c714011..26b7da0 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -119,7 +119,7 @@ func (s *WorktreeSuite) TestPullNonFastForward(c *C) {
c.Assert(err, IsNil)
err = w.Pull(&PullOptions{})
- c.Assert(err, ErrorMatches, "non-fast-forward update")
+ c.Assert(err, Equals, ErrNonFastForwardUpdate)
}
func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) {