summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-05 06:14:06 -0600
committerJeff Carr <[email protected]>2025-01-05 06:14:06 -0600
commit6ded56a13ac7f0e419023e52adae8bd989fe4f94 (patch)
tree963bfa6e0ba5b6dbc2fc733c6eaaf0f8ef5566ae
parent2c7e15ccfacd065029b5de4360288d72815bc907 (diff)
more overall checking for branch changes
-rw-r--r--doCommon.go49
-rw-r--r--windowMain.go30
2 files changed, 71 insertions, 8 deletions
diff --git a/doCommon.go b/doCommon.go
index a085587..110d3ab 100644
--- a/doCommon.go
+++ b/doCommon.go
@@ -4,6 +4,7 @@ import (
"time"
"go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -55,15 +56,34 @@ func doCheckDirtyAndConfigSave() {
}
func IsEverythingOnDevel() bool {
+ me.found = new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetDevelBranchName() {
- log.Info(repo.GetFullPath(), repo.GetCurrentBranchName(), repo.GetDevelBranchName())
- return false
+ // log.Info(repo.GetFullPath(), repo.GetCurrentBranchName(), repo.GetDevelBranchName())
+ me.found.AppendUniqueGoPath(repo)
}
}
- return true
+ if len(me.found.Repos) == 0 {
+ return true
+ }
+ return false
+}
+
+func IsEverythingOnUser() bool {
+ me.found = new(gitpb.Repos)
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
+ me.found.AppendUniqueGoPath(repo)
+ }
+ }
+ if len(me.found.Repos) == 0 {
+ return true
+ }
+ return false
}
func doGitReset() {
@@ -101,3 +121,26 @@ func checkoutBranches(repo *gitpb.Repo) error {
}
return nil
}
+
+func doAllCheckoutDevel() bool {
+ me.forge.CheckoutDevel()
+ me.forge = forgepb.Init()
+ if !IsEverythingOnDevel() {
+ log.Info("switching to devel branch failed")
+ doCobol()
+ badExit(nil)
+ return false
+ }
+ return true
+}
+
+func doAllCheckoutUser() bool {
+ me.forge.CheckoutUser()
+ me.forge = forgepb.Init()
+ if !IsEverythingOnUser() {
+ log.Info("switching to user branch failed")
+ doCobol()
+ return false
+ }
+ return true
+}
diff --git a/windowMain.go b/windowMain.go
index eb55656..c17f766 100644
--- a/windowMain.go
+++ b/windowMain.go
@@ -84,12 +84,32 @@ func globalBuildOptions(vbox *gui.Node) {
me.setBranchB = grid.NewButton("set current branch to:", func() {
targetName := me.newBranch.String()
log.Warn("setting all branches to", targetName)
- loop := me.repos.View.ReposSortByName()
- for loop.Scan() {
- repo := loop.Repo()
- repo.Status.CheckoutBranch(targetName)
- repo.Scan()
+ if targetName == "devel" {
+ if !doAllCheckoutDevel() {
+ okExit("")
+ }
+ return
}
+ if targetName == "master" {
+ log.Info("Don't know how to set", targetName, "yet")
+ return
+ }
+ // just assume user
+ if targetName == "jcarr" {
+ if doAllCheckoutUser() {
+ return
+ }
+ log.Info("switching to user branches failed")
+ return
+ }
+ /*
+ loop := me.repos.View.ReposSortByName()
+ for loop.Scan() {
+ repo := loop.Repo()
+ repo.Status.CheckoutBranch(targetName)
+ repo.Scan()
+ }
+ */
})
me.newBranch = grid.NewCombobox()
me.newBranch.AddText("master")