diff --git a/globalBuildOptions.go b/globalBuildOptions.go index bcbdf72..fd445b2 100644 --- a/globalBuildOptions.go +++ b/globalBuildOptions.go @@ -82,10 +82,42 @@ 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) + var count int 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() + count += 1 } + log.Info("set", count, "branches to", targetName) }) me.newBranch = grid.NewCombobox() me.newBranch.AddText("master") @@ -105,7 +137,7 @@ func globalBuildOptions(vbox *gui.Node) { defer me.Enable() for _, repo := range repolist.AllRepos() { // gitcmd := []string{"git", "fetch", "origin"} - gitcmd := []string{"git", "pull"} + itcmd := []string{"git", "pull"} err, output := repo.RunCmd(gitcmd) log.Info("output =", output) if err == nil {