diff options
| author | Jeff Carr <[email protected]> | 2025-09-04 18:32:10 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-04 18:32:10 -0500 |
| commit | 4cac4386f596b7b81d4c04ce54769c2e78fb4897 (patch) | |
| tree | a1a50ce68c6b2b015a66e967a18f6ac16285e006 | |
| parent | 89e6fd08055fbaa5aa933a59b2cd4a06c40a347d (diff) | |
smarter implementation of CheckDirty()
| -rw-r--r-- | doDirty.go | 52 |
1 files changed, 47 insertions, 5 deletions
@@ -11,18 +11,43 @@ import ( "go.wit.com/log" ) +func (f *Forge) CheckDirtyQuiet() { + start := f.straightCheckDirty() + now := time.Now() + stats := f.RillRepos(doCheckDirty) + end := f.straightCheckDirty() + diff := end - start + + var changed bool + for _, s := range stats { + if s.Err == nil { + } else { + // log.Info(i, s.Err) + f.SetConfigSave(true) + changed = true + } + } + if changed { + log.Printf("dirty check (%d dirty repos) (%d total repos) (%d changed) took:%s\n", end, f.Repos.Len(), diff, shell.FormatDuration(time.Since(now))) + } +} + func (f *Forge) CheckDirty() *gitpb.Repos { start := f.straightCheckDirty() now := time.Now() - f.RillFuncError(doCheckDirty) + stats := f.RillRepos(doCheckDirty) end := f.straightCheckDirty() diff := end - start log.Printf("dirty check (%d dirty repos) (%d total repos) (%d changed) took:%s\n", end, f.Repos.Len(), diff, shell.FormatDuration(time.Since(now))) - // todo: actually detect if this needs to be changed? - f.SetConfigSave(true) - f.ConfigSave() + for i, s := range stats { + if s.Err == nil { + } else { + log.Info(i, s.Err) + f.SetConfigSave(true) + } + } return f.FindDirty() } @@ -38,11 +63,28 @@ func (f *Forge) straightCheckDirty() int { } func doCheckDirty(repo *gitpb.Repo) error { - repo.CheckDirty() // reset these in here for now if repo.GetTargetVersion() != "" { repo.TargetVersion = "" } + + if repo.IsDirty() { + if repo.CheckDirty() { + // nothing changed + } else { + log.Info("Repo changed to clean", repo.FullPath) + // f.SetConfigSave(true) + } + } else { + if repo.CheckDirty() { + log.Info("Repo changed to dirty", repo.FullPath) + return log.Errorf("%s repo changed to dirty", repo.FullPath) + // f.SetConfigSave(true) + } else { + // nothing changed + } + } + return nil } |
