diff options
| -rw-r--r-- | doCheckout.go | 47 | ||||
| -rw-r--r-- | doGui.go | 79 | ||||
| -rw-r--r-- | structs.go | 4 |
3 files changed, 100 insertions, 30 deletions
diff --git a/doCheckout.go b/doCheckout.go index c77c336..0d50f22 100644 --- a/doCheckout.go +++ b/doCheckout.go @@ -250,43 +250,62 @@ func doAllCheckoutMaster() error { return nil } -// trys to figure out if there is still something to update -// todo: redo this logic as it is terrible - -func doCheckout() error { - if argv.Checkout.User != nil { +// shared this with the GUI and the command line? +func doCheckoutShared() error { + if me.argvCheckoutUser { if argv.Force { // make the user directories if err := makeUserBranches(); err != nil { - badExit(err) + return err } - okExit("make user branches done") + return nil } // this uses rill and is super fast doAllCheckoutUser() - okExit("") + return nil } - if argv.Checkout.Devel != nil { + if me.argvCheckoutDevel { if argv.Force { // make the devel directories if err := makeDevelBranches(); err != nil { - badExit(err) + return err } - okExit("make devel branches done") + return nil } // this uses rill and is super fast doAllCheckoutDevel() - okExit("") + return nil } - if argv.Checkout.Master != nil { + if me.argvCheckoutMaster { doAllCheckoutMaster() - okExit("") } return nil } +// trys to figure out if there is still something to update +// todo: redo this logic as it is terrible + +func doCheckout() error { + if argv.Checkout.User != nil { + me.argvCheckoutUser = true + } + + if argv.Checkout.Devel != nil { + me.argvCheckoutDevel = true + } + + if argv.Checkout.Master != nil { + me.argvCheckoutMaster = true + } + if err := doCheckoutShared(); err != nil { + badExit(err) + } + okExit("git checkout done") + return nil +} + func makeDevelBranches() error { all := me.forge.Repos.SortByFullPath() for all.Scan() { @@ -112,30 +112,77 @@ func drawWindow(win *gadgets.BasicWindow) { log.Info("reposWin == nil") reposWin.Hide() } - targetName := me.newBranch.String() - log.Warn("setting all branches to", targetName) - if targetName == "devel" { - if err := doAllCheckoutDevel(); err != nil { - log.Info("switching to devel branches failed") - } - return - } - if targetName == "master" { - if err := doAllCheckoutMaster(); err != nil { - log.Info("switching to master branches failed") - } - return + + if me.autoCreateBranches.Checked() { + argv.Force = true + } else { + argv.Force = false } - // just assume user - if err := doAllCheckoutUser(); err != nil { - log.Info("switching to user branches failed") + if err := doCheckoutShared(); err != nil { + badExit(err) } + /* + targetName := me.newBranch.String() + log.Warn("setting all branches to", targetName) + log.Info("auto create branches =", createBranches) + if targetName == "devel" { + now := time.Now() + if err := doAllCheckoutDevel(); err != nil { + } + total, count, nope, _ := IsEverythingOnDevel() + log.Printf("Devel branch check. %d total repos. (%d ok) (%d not on devel branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now))) + if nope != 0 { + log.Info("switching to devel branches failed") + log.Info("auto create branches =", createBranches) + if createBranches { + } else { + log.Info("You should enable the 'auto create branches' checkbox") + } + } + return + } + if targetName == "master" { + if err := doAllCheckoutMaster(); err != nil { + log.Info("switching to master branches failed") + } + return + } + now := time.Now() + // just assume user + if err := doAllCheckoutUser(); err != nil { + } + total, count, nope, err := IsEverythingOnUser() + log.Printf("User branch check. %d total repos. (%d ok) (%d not on user branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now))) + if err != nil { + log.Info("switching to user branches failed") + log.Info("auto create branches =", createBranches) + if createBranches { + } else { + log.Info("You should enable the 'auto create branches' checkbox") + } + } + */ }) me.newBranch = grid.NewDropdown() me.newBranch.AddText("master") me.newBranch.AddText("devel") me.newBranch.AddText(usr.Username) me.newBranch.SetText(usr.Username) + me.argvCheckoutUser = true + me.newBranch.Custom = func() { + // toggle global values shared by the command line and the gui for doCheckout() + me.argvCheckoutUser = false + me.argvCheckoutDevel = false + me.argvCheckoutMaster = false + switch me.newBranch.String() { + case "master": + me.argvCheckoutMaster = true + case "devel": + me.argvCheckoutDevel = true + default: + me.argvCheckoutUser = true + } + } // checking this will automatically make the branches off of devel me.autoCreateBranches = grid.NewCheckbox("auto create branches").SetChecked(true) @@ -72,4 +72,8 @@ type mainType struct { // the repositories to them newBranch *gui.Node setBranchB *gui.Node + + argvCheckoutUser bool // shared between the GUI and the command line tools + argvCheckoutDevel bool // shared between the GUI and the command line tools + argvCheckoutMaster bool // shared between the GUI and the command line tools } |
