Skip to content

Commit

Permalink
Keep tests passing, decouple more error handlers
Browse files Browse the repository at this point in the history
See also: Masterminds#39
  • Loading branch information
tony committed May 4, 2016
1 parent a98b1c1 commit 81abfb6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bzr.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *BzrRepo) UpdateCmd() (string, []string) {
// Update performs a Bzr pull and update to an existing checkout.
func (s *BzrRepo) Update() error {
name, args := s.UpdateCmd()
out, err := s.run(name, args...)
out, err := s.RunFromDir(name, args...)
if err != nil {
return NewRemoteError("Unable to update repository", err, string(out))
}
Expand Down
9 changes: 7 additions & 2 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ func (s *GitRepo) Update() error {
// Perform a fetch to make sure everything is up to date.
cmd, args := s.FetchCmd()
out, err := s.RunFromDir(cmd, args...)

err = s.FetchError(out, err)
if strings.Contains(err.Error(), "In detached head state, do not pull") {
return nil
if err != nil {
if strings.Contains(err.Error(), "In detached head state, do not pull") {
return nil
} else {
return err
}
}
cmd, args = s.UpdateCmd()
out, err = s.RunFromDir(cmd, args...)
Expand Down
28 changes: 19 additions & 9 deletions hg.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,38 @@ func (s *HgRepo) InitCmd() (string, []string) {
return "hg", []string{"init", s.LocalPath()}
}

func (s *HgRepo) InitError(out []byte, err error) error {
if err != nil {
return NewLocalError("Unable to initialize repository", err, string(out))
}
return err
}

// Init will initialize a mercurial repository at local location.
func (s *HgRepo) Init() error {
name, args := s.InitCmd()
out, err := s.run(name, args...)
if err != nil {
return NewLocalError("Unable to initialize repository", err, string(out))
}
return nil

return s.InitError(out, err)
}

func (s *HgRepo) UpdateCmd() (string, []string) {
return "hg", []string{"update"}
}

// Update performs a Mercurial pull to an existing checkout.
func (s *HgRepo) Update() error {
name, args := s.UpdateCmd()
out, err := s.run(name, args...)
func (s *HgRepo) UpdateError(out []byte, err error) error {
if err != nil {
return NewRemoteError("Unable to update repository", err, string(out))
}
return nil
return err
}

// Update performs a Mercurial pull to an existing checkout.
func (s *HgRepo) Update() error {
name, args := s.UpdateCmd()
out, err := s.RunFromDir(name, args...)

return s.UpdateError(out, err)
}

// UpdateVersion sets the version of a package currently checked out via Hg.
Expand Down
2 changes: 1 addition & 1 deletion svn.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *SvnRepo) Get() error {
}

func (s *SvnRepo) InitCmd() (string, []string) {
return "svn", []string{"svnadmin", "create", s.Remote()}
return "svnadmin", []string{"create", s.Remote()}
}

// Init will create a svn repository at remote location.
Expand Down

0 comments on commit 81abfb6

Please sign in to comment.