summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doClean.go44
-rw-r--r--doGui.go29
2 files changed, 57 insertions, 16 deletions
diff --git a/doClean.go b/doClean.go
index 40c3272..3cdfb89 100644
--- a/doClean.go
+++ b/doClean.go
@@ -174,13 +174,23 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
brmaster := repo.GetMasterBranchName()
if repo.IsBranchRemote(bruser) {
- b1 := repo.CountDiffObjects(bruser, "refs/heads/"+brdevel) // should be zero
- if b1 == 0 {
- log.Info("Local user branch is safe to delete", bruser)
+ b2, err := repo.CountDiffObjects("refs/heads/"+bruser, "refs/heads/"+brmaster) // should be zero
+ if err != nil {
+ log.Info(repo.FullPath, "doRepoCleanUser() bad branches")
+ return err
}
- b2 := repo.CountDiffObjects("refs/heads/"+bruser, "refs/heads/"+brmaster) // should be zero
if b2 == 0 {
log.Info("Local remote branch is safe to delete (is completely in master)", bruser)
+ cmd := []string{"git", "branch", "-D", bruser}
+ s := log.Sprintf("Run: %v in %s", cmd, repo.FullPath)
+ if !argv.Force {
+ if fhelp.QuestionUser(s) {
+ repo.RunVerbose([]string{"git", "branch", "-D", bruser})
+ // repo.RunVerbose([]string{"git", "checkout", bname})
+ }
+ } else {
+ repo.RunVerbose([]string{"git", "branch", "-D", bruser})
+ }
}
log.Info("forge is designed to always have local only user branches", bruser)
return fmt.Errorf("forge is designed to always have local only user branches")
@@ -196,7 +206,11 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
// then if UserBranchCommits exist in DevelBranch
// DeleteUserBranch is safe
if repo.IsLocalBranch(brdevel) {
- b1 := repo.CountDiffObjects(bruser, "refs/heads/"+brdevel) // should be zero
+ b1, err := repo.CountDiffObjects(bruser, "refs/heads/"+brdevel) // should be zero
+ if err != nil {
+ log.Info(repo.FullPath, "doRepoCleanUser() bad branches")
+ return err
+ }
if b1 == 0 {
// every user branch exists in devel. delete user branch
cmd := []string{"git", "branch", "-D", bruser}
@@ -211,7 +225,11 @@ func doRepoCleanUser(repo *gitpb.Repo) error {
// then if all user commits exist in master
// delete user branch is safe
if repo.IsLocalBranch(brmaster) {
- b1 := repo.CountDiffObjects(bruser, "refs/heads/"+brmaster) // should be zero
+ b1, err := repo.CountDiffObjects(bruser, "refs/heads/"+brmaster) // should be zero
+ if err != nil {
+ log.Info(repo.FullPath, "doRepoCleanUser() bad branches")
+ return err
+ }
if b1 == 0 {
cmd := []string{"git", "branch", "-D", bruser}
// log.Info("USER IS IN DEVEL", repo.GetGoPath(), cmd)
@@ -240,7 +258,11 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {
// check against remote if it exists
if repo.IsDevelRemote() {
- b1 := repo.CountDiffObjects(branch, remote) // should be zero
+ b1, err := repo.CountDiffObjects(branch, remote) // should be zero
+ if err != nil {
+ log.Info(repo.FullPath, "doRepoCleanUser() bad branches")
+ return err
+ }
if b1 == 0 {
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
// log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
@@ -249,13 +271,17 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {
}
cmd := []string{"git", "push"}
log.Info("DEVEL LOCAL NEEDS GIT PUSH TO REMOTE", repo.GetGoPath(), cmd)
- err := repo.RunVerbose(cmd)
+ err = repo.RunVerbose(cmd)
return err
}
// remote doesn't exist, check against master
master := repo.GetMasterBranchName()
- b1 := repo.CountDiffObjects(branch, "refs/heads/"+master) // should be zero
+ b1, err := repo.CountDiffObjects(branch, "refs/heads/"+master) // should be zero
+ if err != nil {
+ log.Info(repo.FullPath, "doRepoCleanUser() bad branches")
+ return err
+ }
if b1 == 0 {
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
// log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
diff --git a/doGui.go b/doGui.go
index db03508..6906812 100644
--- a/doGui.go
+++ b/doGui.go
@@ -173,7 +173,12 @@ func findMergeToDevel() *gitpb.Repos {
for repo := range me.forge.Repos.IterByFullPath() {
// this sees if user has patches for devel. If it does, add it to found
- if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 {
+ i, err := repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName())
+ if err != nil {
+ found.AppendByFullPath(repo)
+ continue
+ }
+ if i > 0 {
found.AppendByFullPath(repo)
}
}
@@ -211,15 +216,22 @@ func findMergeToMaster() *gitpb.Repos {
*/
// this sees if devel is behind master. IT SHOULD NOT BE
- if repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName()) == 0 {
+ i, err := repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName())
+ if err != nil {
+ repo.State = "findMergeToMaster() diff err"
+ continue
+ }
+ if i == 0 {
// everything is normal
} else {
- repo.State = "DEVEL < MASTER"
+ repo.State = "DEVEL != MASTER"
log.Info("SERIOUS ERROR. DEVEL BRANCH IS BEHIND MASTER", repo.GetNamespace())
}
+ i, err = repo.CountDiffObjects(repo.GetDevelBranchName(), repo.GetMasterBranchName())
// this sees if devel has patches for master. If it does, add it to me.found
- if repo.CountDiffObjects(repo.GetDevelBranchName(), repo.GetMasterBranchName()) > 0 {
+ if i > 0 {
+ repo.State = log.Sprintf("dev has %d patches", i)
found.AppendByFullPath(repo)
}
}
@@ -292,14 +304,17 @@ func mergeUserToDevel(doit bool) {
if repo.GetUserVersion() == "uerr" {
// no user branch
- return
+ continue
}
log.Info("trying", bruser, repo.GetUserVersion())
- b1 := repo.CountDiffObjects(bruser, brdevel) // should be zero
+ b1, err := repo.CountDiffObjects(bruser, brdevel) // should be zero
+ if err != nil {
+ log.Info("bad branches", err, bruser, repo.GetUserVersion())
+ }
if b1 == 0 {
// log.Info("User is already merged into Devel", repo.GetNamespace(), cmd)
- return
+ continue
}
log.Info("merging user into devel repo:", repo.GetNamespace())
if result, err := repo.MergeToDevel(); err == nil {