summaryrefslogtreecommitdiff
path: root/doCheckout.go
diff options
context:
space:
mode:
Diffstat (limited to 'doCheckout.go')
-rw-r--r--doCheckout.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/doCheckout.go b/doCheckout.go
index e2598ab..c77c336 100644
--- a/doCheckout.go
+++ b/doCheckout.go
@@ -5,6 +5,7 @@ package main
import (
"fmt"
+ "path/filepath"
"time"
"go.wit.com/lib/gui/shell"
@@ -254,11 +255,27 @@ func doAllCheckoutMaster() error {
func doCheckout() error {
if argv.Checkout.User != nil {
+ if argv.Force {
+ // 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.Force {
+ // 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("")
}
@@ -269,3 +286,45 @@ func doCheckout() error {
}
return nil
}
+
+func makeDevelBranches() error {
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ branch := repo.GetDevelBranchName()
+ if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
+ continue
+ }
+ if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) {
+ cmd := []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ continue
+ }
+ cmd := []string{"git", "branch", branch}
+ repo.RunVerbose(cmd)
+ cmd = []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ }
+ return nil
+}
+
+func makeUserBranches() error {
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ branch := repo.GetUserBranchName()
+ if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
+ continue
+ }
+ if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) {
+ cmd := []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ continue
+ }
+ cmd := []string{"git", "branch", branch}
+ repo.RunVerbose(cmd)
+ cmd = []string{"git", "checkout", branch}
+ repo.RunVerbose(cmd)
+ }
+ return nil
+}