actually create the user branches

This commit is contained in:
Jeff Carr 2024-02-22 05:24:02 -06:00
parent c57b1a2155
commit ec63197c81
1 changed files with 34 additions and 2 deletions

View File

@ -82,10 +82,42 @@ func globalBuildOptions(vbox *gui.Node) {
me.setBranchB = grid.NewButton("set current branch to:", func() { me.setBranchB = grid.NewButton("set current branch to:", func() {
targetName := me.newBranch.String() targetName := me.newBranch.String()
log.Warn("setting all branches to", targetName) log.Warn("setting all branches to", targetName)
var count int
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
repo.Status.CheckoutBranch(targetName) if repo.ReadOnly() {
continue
}
if targetName == repo.Status.GetCurrentBranchName() {
continue
}
if repo.Status.BranchExists(targetName) {
ok := repo.Status.CheckoutBranch(targetName)
if ok {
// checkout went fine
continue
}
log.Info("couldn't set", repo.Status.Path(), "branch to", targetName)
log.Info("but branch exists so something went wrong")
continue
}
if ! me.autoCreateBranches.Checked() {
log.Info("not auto creating branch", targetName)
continue
}
// branch doesn't exist. make it
// todo: make this branch from 'devel' branch if it exists
log.Info("should make the", targetName, "branch here!")
if me.autoCreateBranches.Checked() {
log.Info("going to make the branch!")
repo.Status.RunCmd([]string{"git", "branch", targetName})
repo.Status.RunCmd([]string{"git", "checkout", targetName})
} else {
log.Info("not auto creating branch", targetName)
}
repo.Scan() repo.Scan()
count += 1
} }
log.Info("set", count, "branches to", targetName)
}) })
me.newBranch = grid.NewCombobox() me.newBranch = grid.NewCombobox()
me.newBranch.AddText("master") me.newBranch.AddText("master")
@ -105,7 +137,7 @@ func globalBuildOptions(vbox *gui.Node) {
defer me.Enable() defer me.Enable()
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
// gitcmd := []string{"git", "fetch", "origin"} // gitcmd := []string{"git", "fetch", "origin"}
gitcmd := []string{"git", "pull"} itcmd := []string{"git", "pull"}
err, output := repo.RunCmd(gitcmd) err, output := repo.RunCmd(gitcmd)
log.Info("output =", output) log.Info("output =", output)
if err == nil { if err == nil {