more overall checking for branch changes

This commit is contained in:
Jeff Carr 2025-01-05 06:14:06 -06:00
parent 2c7e15ccfa
commit 6ded56a13a
2 changed files with 71 additions and 8 deletions

View File

@ -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
}

View File

@ -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")