Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1064 from asv/sentinel_error_for_no_ff_update
Browse files Browse the repository at this point in the history
worktree: add sentinel error for non-fast-forward pull
  • Loading branch information
mcuadros committed Feb 8, 2019
2 parents 00629a1 + cf6cf0d commit dcc9f37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions worktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion worktree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dcc9f37

Please sign in to comment.