From 035b4eb44323e8d3b8f522b7144ba154a20b57cf Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 29 Feb 2024 19:16:45 -0600 Subject: quiet git pull --- git.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'git.go') diff --git a/git.go b/git.go index c4714ca..abf58c0 100644 --- a/git.go +++ b/git.go @@ -40,23 +40,13 @@ func (rs *RepoStatus) Age() time.Duration { return time.Since(tagTime) } -func (rs *RepoStatus) GitPull() error { +var ErrorMissingGitConfig error = errors.New("missing .git/config") +var ErrorGitPullOnLocal error = errors.New("git pull on local only branch") + +func (rs *RepoStatus) GitPull() (string, error) { currentName := rs.GetCurrentBranchName() if rs.IsOnlyLocalTag(currentName) { - log.Log(REPOWARN, rs.Path(), "can not git pull on local only branch", currentName) - return nil - } - var found bool = false - // okay, it's not local. Is it mapped in .git/config ? - for name, branch := range rs.gitConfig.branches { - log.Log(WARN, name, "remote:", branch.remote, "merge", branch.merge) - if name == currentName { - log.Log(WARN, "Found:", name, "remote:", branch.remote, "merge", branch.merge) - found = true - } - } - if !found { - return errors.New("git config error") + return "", ErrorGitPullOnLocal } var cmd []string cmd = append(cmd, "git", "pull") @@ -70,7 +60,7 @@ func (rs *RepoStatus) GitPull() error { } else { log.Log(REPOWARN, "git pull error", rs.Path(), err) } - return err + return output, err } /* -- cgit v1.2.3