From a1f751beb2bb8ba459c5bb250916eebae11229f8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 25 Sep 2025 05:03:28 -0500 Subject: [PATCH] do verify handling here --- doNormal.go | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/doNormal.go b/doNormal.go index b51e7a6..bfae45d 100644 --- a/doNormal.go +++ b/doNormal.go @@ -6,11 +6,14 @@ package main // checks that repos are in a "normal" state import ( + "errors" + "fmt" "path/filepath" "strings" "time" "go.wit.com/lib/config" + "go.wit.com/lib/fhelp" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -29,6 +32,15 @@ func doNormal() bool { if stat.Err == nil { continue } + repo := me.forge.Repos.FindByFullPath(path) + if stat.Err == ErrorLocalDevelBranch { + bname := repo.GetMasterBranchName() + s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath) + if fhelp.QuestionUser(s) { + repo.RunVerbose([]string{"git", "branch", "-D", bname}) + repo.RunVerbose([]string{"git", "checkout", bname}) + } + } // log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path) // log.Infof("%-30v %s %v\n", dur, path, stat.Err) // log.Info("got path", path, stat.Err) @@ -44,6 +56,9 @@ func doNormal() bool { return true } +var ErrorLocalDevelBranch error = errors.New("devel branch problem") +var ErrorLocalMasterBranch error = errors.New("master branch problem") + // 99% of the time, the repos during development should be on your user branch. // error out if it's not // this checks to see if a devel and user branch exist @@ -93,8 +108,28 @@ func checkNormalRepoState(repo *gitpb.Repo) error { } repo.MakeLocalDevelBranch() - repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) - repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) + if !repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) { + return ErrorLocalDevelBranch + /* + bname := repo.GetDevelBranchName() + s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath) + if fhelp.QuestionUser(s) { + repo.RunVerbose([]string{"git", "branch", "-D", bname}) + repo.RunVerbose([]string{"git", "checkout", bname}) + } + */ + } + if !repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) { + return ErrorLocalMasterBranch + /* + bname := repo.GetMasterBranchName() + s := fmt.Sprintf("repair the %s branch on %s", bname, repo.FullPath) + if fhelp.QuestionUser(s) { + repo.RunVerbose([]string{"git", "branch", "-D", bname}) + repo.RunVerbose([]string{"git", "checkout", bname}) + } + */ + } if repo.GetCurrentBranchName() != repo.GetUserBranchName() { log.Infof("changing to user(%s) branch: %s\n", repo.GetUserBranchName(), repo.FullPath)