diff options
| -rw-r--r-- | branches.go | 5 | ||||
| -rw-r--r-- | reloadRepoState.go | 7 | ||||
| -rw-r--r-- | shell.go | 6 |
3 files changed, 12 insertions, 6 deletions
diff --git a/branches.go b/branches.go index 490fd16..7b256bb 100644 --- a/branches.go +++ b/branches.go @@ -85,7 +85,10 @@ func (repo *Repo) DeleteLocalDevelBranch() error { return fmt.Errorf("no remote branch") } - b1 := repo.CountDiffObjects(branch, remote) // should be zero + b1, err := repo.CountDiffObjects(branch, remote) // should be zero + if err != nil { + return err + } if b1 == 0 { cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()} _, err := repo.RunVerboseOnError(cmd) diff --git a/reloadRepoState.go b/reloadRepoState.go index 42482c4..923a50f 100644 --- a/reloadRepoState.go +++ b/reloadRepoState.go @@ -28,12 +28,15 @@ func (repo *Repo) setRepoState() { repo.State = "no devel branch" return } - b1 := repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName()) + b1, err := repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName()) + if err != nil { + repo.State = "git log err" + } if b1 == 0 { repo.State = "merge to main" // log.Info("master vs devel count is normal b1 == 0", b1) } else { - repo.State = "DEVEL behind MASTER" + repo.State = log.Sprintf("DEVEL < MASTER by %d", b1) // log.Info("master vs devel count b1 != 0", b1) log.Infof("%s devel branch is behind master branch (missing %d commits)\n", repo.GetGoPath(), b1) } @@ -178,14 +178,14 @@ func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string { } // count all objects only in branch1 -func (repo *Repo) CountDiffObjects(branch1, branch2 string) int { +func (repo *Repo) CountDiffObjects(branch1, branch2 string) (int, error) { cmd := repo.ConstructGitDiffLog(branch1, branch2) r, err := repo.RunVerboseOnError(cmd) if err != nil { - return -1 + return -1, err } // log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " ")) - return len(r.Stdout) + return len(r.Stdout), err } func (repo *Repo) RunPipe(cmd1 []string, cmd2 []string) cmd.Status { |
