finally detecting state changes again

This commit is contained in:
Jeff Carr 2025-09-11 06:31:24 -05:00
parent 309fcffc86
commit 363460290d
2 changed files with 30 additions and 3 deletions

View File

@ -6,22 +6,29 @@ package main
import (
"fmt"
"path/filepath"
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func checkRemoteBranches(repo *gitpb.Repo) error {
if err := repo.ReloadCheck(); err != nil {
log.Info("need to reload", repo.FullPath)
}
if repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName()) {
} else {
repo.Reload()
me.forge.SetConfigSave(true)
return log.Errorf("devel is bad")
return log.Errorf("remote devel is out of sync with local")
}
if repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName()) {
} else {
repo.Reload()
me.forge.SetConfigSave(true)
return log.Errorf("master is bad")
return log.Errorf("remote master is out of sync with local")
}
return nil
}
@ -33,7 +40,17 @@ func doClean() error {
if argv.Clean.Verify != nil {
stats := me.forge.RillRepos(checkRemoteBranches)
_ = stats
for path, stat := range stats {
if stat.Err == nil {
continue
}
dur := stat.End.Sub(stat.Start)
if dur > time.Second {
log.Infof("%s checkRemoteBranches() took a long time (%s) (err=%v)\n", path, shell.FormatDuration(dur), stat.Err)
}
}
// log.Infof("%-60s, %-60s %v %s\n", stat.Start, stat.End.String(), dur, path)
// log.Infof("%-30v %s %v\n", dur, path, stat.Err)
return nil
}

10
main.go
View File

@ -43,6 +43,15 @@ func getVersion(repo *gitpb.Repo, name string) string {
return strings.TrimSpace(output)
}
func reloadCheck(repo *gitpb.Repo) error {
if err := repo.ReloadCheck(); err != nil {
log.Info("need to reload", repo.FullPath)
configSave = true
return err
}
return nil
}
func main() {
me = new(mainType)
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
@ -50,6 +59,7 @@ func main() {
me.pp = arg.MustParse(&argv)
me.forge = forgepb.Init()
me.forge.RillRepos(reloadCheck)
me.forge.ScanGoSrc()
// initialize patches