diff options
| author | Jeff Carr <[email protected]> | 2025-10-27 18:38:14 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-27 18:38:14 -0500 |
| commit | e5cd179c5887de8287fc0faed31838db06cca27e (patch) | |
| tree | fdb87e69282d52be3653f61b5a88a072b0db5e56 /doClean.go | |
| parent | 16ec641ec1dcc2192374ef2e3f76f192f64d329d (diff) | |
getting help back slowly
Diffstat (limited to 'doClean.go')
| -rw-r--r-- | doClean.go | 73 |
1 files changed, 24 insertions, 49 deletions
@@ -8,8 +8,8 @@ import ( "fmt" "path/filepath" + "go.wit.com/lib/env" "go.wit.com/lib/fhelp" - "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) @@ -42,19 +42,16 @@ func doResetRepo(repo *gitpb.Repo) error { func doClean() (string, error) { var s string var err error - - if argv.Clean.List != nil { - s, err = doCleanList() - return s, err - } + var allerr error if me.forge.IsModeNormal() { s := fmt.Sprintf("Reset all (%d) git repos to the original state (non-destructive)?", me.forge.Repos.Len()) if !fhelp.QuestionUser(s) { s, err = doModeMaster() + allerr = errors.Join(allerr, err) } } - me.forge.SetMode(forgepb.ForgeMode_CLEAN) + me.forge.SetCleaningMode() // fix this to work, then delete all the other options for "forge clean' if err := me.forge.DoAllCheckoutMaster(); err != nil { @@ -62,56 +59,34 @@ func doClean() (string, error) { } me.forge.RescanRepos() // looks for new dirs, checks existing repos for changes + notclean := gitpb.NewRepos() all := me.forge.Repos.SortByFullPath() for all.Scan() { repo := all.Next() - doResetRepo(repo) - } - - me.forge.RescanRepos() // looks for new dirs, checks existing repos for changes - return "all repos should be clean", nil -} - -func doCleanList() (string, error) { - found := gitpb.NewRepos() - - total := 0 - // find all repos that aren't "clean" - for repo := range me.forge.Repos.IterByFullPath() { - total += 1 - - // find repos not on master branch - if repo.GetCurrentBranchName() != repo.GetMasterBranchName() { - found.AppendByFullPath(repo) - continue - } - - // find dirty repos - if repo.IsDirty() { - found.AppendByFullPath(repo) - continue - } - - // find repos that still have a local user branch - if repo.IsLocalBranch(repo.GetUserBranchName()) { - found.AppendByFullPath(repo) - continue + err := doResetRepo(repo) + if err != nil { + newr := notclean.Clone(repo) + newr.State = fmt.Sprintf("%v", err) + allerr = errors.Join(allerr, err) } + } - // find repos that still have a local devel branch - if repo.IsLocalBranch(repo.GetDevelBranchName()) { - found.AppendByFullPath(repo) - continue + if notclean.Len() > 0 { + if env.True("--force") { + // try to force the issue + for r := range notclean.IterAll() { + log.Info("FORCE THE ISSUE", r.FullPath) + } + } else { + log.Info("NOT FORCEING THE ISSUE") } + footer := me.forge.NormalCheckTB(notclean) + s = fmt.Sprintf("(%d) not clean repos %s", notclean.Len(), footer) + allerr = errors.Join(allerr, errors.New(s)) + return s, allerr } - var s string - if found.Len() == 0 { - s = log.Sprintf("%d repos are not clean", found.Len()) - } else { - s = log.Sprintf("All %d repos are clean", me.forge.Repos.Len()) - } - return s, nil + return "all repos are clean", nil } func doRepoCleanDevel(repo *gitpb.Repo) error { |
