diff --git a/bzr.go b/bzr.go index ee1a302..1e0eb4b 100644 --- a/bzr.go +++ b/bzr.go @@ -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)) } diff --git a/git.go b/git.go index 2f5782a..e39fb26 100644 --- a/git.go +++ b/git.go @@ -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...) diff --git a/hg.go b/hg.go index e1c7852..5e76d6a 100644 --- a/hg.go +++ b/hg.go @@ -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. diff --git a/svn.go b/svn.go index 3d4044c..b6eec3a 100644 --- a/svn.go +++ b/svn.go @@ -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.