summaryrefslogtreecommitdiff
path: root/doCheckout.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-19 07:05:45 -0600
committerJeff Carr <[email protected]>2025-01-19 07:05:45 -0600
commitf0f11794edf1a4a79c310ba66886572ce2f80827 (patch)
treee6b8b03f2b1adfea963cc9573933e168702dae5f /doCheckout.go
parent1e8bdc5c53ccc9539f78d0584f1bac3621b8ff4d (diff)
delete user branches works
Diffstat (limited to 'doCheckout.go')
-rw-r--r--doCheckout.go61
1 files changed, 30 insertions, 31 deletions
diff --git a/doCheckout.go b/doCheckout.go
index bbb6a5b..03904e8 100644
--- a/doCheckout.go
+++ b/doCheckout.go
@@ -3,7 +3,6 @@ package main
import (
"fmt"
- "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -15,6 +14,7 @@ var ErrorNotAllReposOnUser error = fmt.Errorf("not all repos on are on the user
func IsEverythingOnMaster() error {
var total int
var count int
+ var nope int
// first make sure every repo is on the master branch
all := me.forge.Repos.All()
@@ -23,9 +23,11 @@ func IsEverythingOnMaster() error {
total += 1
if repo.GetMasterBranchName() == repo.GetCurrentBranchName() {
count += 1
+ } else {
+ nope += 1
}
}
- log.Printf("Master branch check. %d total repos. %d repos on the master branch\n", total, count)
+ log.Printf("Master branch check. %d total repos. (%d ok) (%d not on master branch)\n", total, count, nope)
if total != count {
// log.Info(ErrorNotAllReposOnMaster)
return ErrorNotAllReposOnMaster
@@ -90,27 +92,6 @@ func doGitReset() {
}
}
-/*
-func checkoutBranches(repo *gitpb.Repo) error {
- dname := repo.GetDevelBranchName()
- if dname == "" {
- if err := me.forge.MakeDevelBranch(repo); err != nil {
- log.Info("verify() no devel branch name", repo.GetGoPath())
- return err
- }
- configSave = true
- }
- if repo.GetUserBranchName() == "" {
- if err := me.forge.MakeUserBranch(repo); err != nil {
- log.Info("verify() no devel branch name", repo.GetGoPath())
- return err
- }
- configSave = true
- }
- return nil
-}
-*/
-
func rillCheckoutUser(repo *gitpb.Repo) error {
if repo.IsDirty() {
// never do dirty repos
@@ -147,15 +128,37 @@ func doAllCheckoutUser() error {
return nil
}
+func rillCheckoutDevel(repo *gitpb.Repo) error {
+ if repo.IsDirty() {
+ // never do dirty repos
+ return nil
+ }
+ if repo.GetCurrentBranchName() == repo.GetDevelBranchName() {
+ // repo is already on devel branch
+ return nil
+ }
+ repo.CheckoutDevel()
+ return nil
+}
+
func doAllCheckoutDevel() error {
- me.forge.CheckoutDevel()
- // me.forge = forgepb.Init()
+ me.forge.RillFuncError(rillCheckoutDevel)
count := me.forge.RillReload()
- log.Info("CHECKOUT DEVEL COUNT", count)
if count != 0 {
me.forge.ConfigSave()
}
if err := IsEverythingOnDevel(); err != nil {
+ // display all repos not on user
+ me.found = new(gitpb.Repos)
+ all := me.forge.Repos.SortByFullPath()
+ for all.Scan() {
+ repo := all.Next()
+ if repo.GetCurrentBranchName() != repo.GetDevelBranchName() {
+ me.found.AppendByGoPath(repo)
+ }
+ }
+ me.forge.PrintHumanTable(me.found)
+ log.Printf("There are %d repos that are NOT on the devel branch\n", me.found.Len())
return err
}
return nil
@@ -224,11 +227,7 @@ func doCheckout() error {
}
if argv.Checkout.Devel != nil {
- me.forge.CheckoutDevel()
- me.forge = forgepb.Init()
- me.found = new(gitpb.Repos)
- argv.Checkout.Devel.findRepos()
- me.forge.PrintHumanTable(me.found)
+ doAllCheckoutDevel()
okExit("")
}