summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-24 04:50:31 -0600
committerJeff Carr <[email protected]>2024-02-24 04:50:31 -0600
commitddd95e9afc926d9e0a4a372dbf433d81c3db3207 (patch)
tree2b0e6788c5a877c528d4287be2de90de51795c9b /git.go
parent2a62d23482aefc506b9cbb4114edb4c368830194 (diff)
GitPull() detects local only branches
Diffstat (limited to 'git.go')
-rw-r--r--git.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/git.go b/git.go
index 02563a5..470882b 100644
--- a/git.go
+++ b/git.go
@@ -40,9 +40,29 @@ func (rs *RepoStatus) Age() time.Duration {
}
func (rs *RepoStatus) GitPull() 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")
+ }
var cmd []string
cmd = append(cmd, "git", "pull")
- err, _, output := RunCmd(rs.realPath.String(), cmd)
+ err, output := rs.RunCmd(cmd)
+ if err != nil {
+ output = "git error_,,,_a_,,,_b_,,,c"
+ }
if err == nil {
log.Log(REPOWARN, "git pull ran", rs.Path())
log.Log(REPOWARN, "git pull output", output)