fix checkout user

This commit is contained in:
Jeff Carr 2025-01-19 04:31:38 -06:00
parent 193d041306
commit 1e8bdc5c53
2 changed files with 29 additions and 20 deletions

View File

@ -62,7 +62,7 @@ func IsEverythingOnUser() error {
for all.Scan() {
repo := all.Next()
total += 1
if repo.GetUserBranchName() == repo.GetUserBranchName() {
if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
count += 1
}
}
@ -111,15 +111,37 @@ func checkoutBranches(repo *gitpb.Repo) error {
}
*/
func rillCheckoutUser(repo *gitpb.Repo) error {
if repo.IsDirty() {
// never do dirty repos
return nil
}
if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
// repo is already on user branch
return nil
}
repo.CheckoutUser()
return nil
}
func doAllCheckoutUser() error {
me.forge.CheckoutUser()
// me.forge = forgepb.Init()
me.forge.RillFuncError(rillCheckoutUser)
count := me.forge.RillReload()
log.Info("CHECKOUT USER COUNT", count)
if count != 0 {
me.forge.ConfigSave()
}
if err := IsEverythingOnUser(); err != nil {
// display all repos not on user
me.found = new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
me.found.AppendByGoPath(repo)
}
}
me.forge.PrintHumanTable(me.found)
log.Printf("There are %d repos that are NOT on the user branch\n", me.found.Len())
return err
}
return nil
@ -197,18 +219,7 @@ func doAllCheckoutMaster() error {
func doCheckout() error {
if argv.Checkout.User != nil {
if argv.Force {
me.forge.CheckoutUserForce()
} else {
me.forge.CheckoutUser()
}
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
argv.Checkout.User.findRepos()
me.forge.PrintHumanTable(me.found)
if err := IsEverythingOnUser(); err != nil {
badExit(err)
}
doAllCheckoutUser()
okExit("")
}
@ -223,6 +234,7 @@ func doCheckout() error {
if argv.Checkout.Master != nil {
doAllCheckoutMaster()
okExit("")
}
return nil
}

View File

@ -176,10 +176,7 @@ func (r *repoWindow) repoMenu() *gui.Node {
if !r.mergeAllDevelToMain() {
return
}
if !me.forge.CheckoutMaster() {
return
}
me.forge.ConfigSave()
doAllCheckoutUser()
os.Exit(0)
})