doCheckout() shared between GUI and command line
This commit is contained in:
parent
d7d2e0ba1b
commit
5171aca31f
|
@ -250,40 +250,59 @@ func doAllCheckoutMaster() error {
|
||||||
return nil
|
return 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 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// this uses rill and is super fast
|
||||||
|
doAllCheckoutUser()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if me.argvCheckoutDevel {
|
||||||
|
if argv.Force {
|
||||||
|
// make the devel directories
|
||||||
|
if err := makeDevelBranches(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// this uses rill and is super fast
|
||||||
|
doAllCheckoutDevel()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if me.argvCheckoutMaster {
|
||||||
|
doAllCheckoutMaster()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// trys to figure out if there is still something to update
|
// trys to figure out if there is still something to update
|
||||||
// todo: redo this logic as it is terrible
|
// todo: redo this logic as it is terrible
|
||||||
|
|
||||||
func doCheckout() error {
|
func doCheckout() error {
|
||||||
if argv.Checkout.User != nil {
|
if argv.Checkout.User != nil {
|
||||||
if argv.Force {
|
me.argvCheckoutUser = true
|
||||||
// make the user directories
|
|
||||||
if err := makeUserBranches(); err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
okExit("make user branches done")
|
|
||||||
}
|
|
||||||
// this uses rill and is super fast
|
|
||||||
doAllCheckoutUser()
|
|
||||||
okExit("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout.Devel != nil {
|
if argv.Checkout.Devel != nil {
|
||||||
if argv.Force {
|
me.argvCheckoutDevel = true
|
||||||
// make the devel directories
|
|
||||||
if err := makeDevelBranches(); err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
okExit("make devel branches done")
|
|
||||||
}
|
|
||||||
// this uses rill and is super fast
|
|
||||||
doAllCheckoutDevel()
|
|
||||||
okExit("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout.Master != nil {
|
if argv.Checkout.Master != nil {
|
||||||
doAllCheckoutMaster()
|
me.argvCheckoutMaster = true
|
||||||
okExit("")
|
|
||||||
}
|
}
|
||||||
|
if err := doCheckoutShared(); err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
okExit("git checkout done")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
49
doGui.go
49
doGui.go
|
@ -112,11 +112,32 @@ func drawWindow(win *gadgets.BasicWindow) {
|
||||||
log.Info("reposWin == nil")
|
log.Info("reposWin == nil")
|
||||||
reposWin.Hide()
|
reposWin.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if me.autoCreateBranches.Checked() {
|
||||||
|
argv.Force = true
|
||||||
|
} else {
|
||||||
|
argv.Force = false
|
||||||
|
}
|
||||||
|
if err := doCheckoutShared(); err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
/*
|
||||||
targetName := me.newBranch.String()
|
targetName := me.newBranch.String()
|
||||||
log.Warn("setting all branches to", targetName)
|
log.Warn("setting all branches to", targetName)
|
||||||
|
log.Info("auto create branches =", createBranches)
|
||||||
if targetName == "devel" {
|
if targetName == "devel" {
|
||||||
|
now := time.Now()
|
||||||
if err := doAllCheckoutDevel(); err != nil {
|
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("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
|
return
|
||||||
}
|
}
|
||||||
|
@ -126,16 +147,42 @@ func drawWindow(win *gadgets.BasicWindow) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
now := time.Now()
|
||||||
// just assume user
|
// just assume user
|
||||||
if err := doAllCheckoutUser(); err != nil {
|
if err := doAllCheckoutUser(); err != nil {
|
||||||
log.Info("switching to user branches failed")
|
|
||||||
}
|
}
|
||||||
|
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 = grid.NewDropdown()
|
||||||
me.newBranch.AddText("master")
|
me.newBranch.AddText("master")
|
||||||
me.newBranch.AddText("devel")
|
me.newBranch.AddText("devel")
|
||||||
me.newBranch.AddText(usr.Username)
|
me.newBranch.AddText(usr.Username)
|
||||||
me.newBranch.SetText(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
|
// checking this will automatically make the branches off of devel
|
||||||
me.autoCreateBranches = grid.NewCheckbox("auto create branches").SetChecked(true)
|
me.autoCreateBranches = grid.NewCheckbox("auto create branches").SetChecked(true)
|
||||||
|
|
|
@ -72,4 +72,8 @@ type mainType struct {
|
||||||
// the repositories to them
|
// the repositories to them
|
||||||
newBranch *gui.Node
|
newBranch *gui.Node
|
||||||
setBranchB *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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue