diff options
| author | Jeff Carr <[email protected]> | 2025-10-10 03:01:13 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-10 03:01:13 -0500 |
| commit | 17652d4ddc35b9acddeeaaf744b111ed03b3b8ba (patch) | |
| tree | 7b85f05289fca92695ffb430529e6ca7c54990b5 | |
| parent | 8e7b9bf81e776048d9f6d0fab7a605eb4db21a2b (diff) | |
code for testiong dirty() problem
| -rw-r--r-- | config.go | 13 | ||||
| -rw-r--r-- | reloadCheckDirty.go | 16 |
2 files changed, 24 insertions, 5 deletions
@@ -14,6 +14,19 @@ import ( "go.wit.com/log" ) +var globalChanged bool +var globalReason string + +func (all *Repos) SmartSave() error { + if !globalChanged { + return nil + } + log.Info("saved because", globalReason) + globalChanged = false + globalReason = "" + return all.Save() +} + // write the repos.pb file func (all *Repos) ConfigSave(fname string) error { if all == nil { diff --git a/reloadCheckDirty.go b/reloadCheckDirty.go index 69b6e52..de7e512 100644 --- a/reloadCheckDirty.go +++ b/reloadCheckDirty.go @@ -44,9 +44,13 @@ func (repo *Repo) CheckDirty() bool { log.Error(r.Error, "CheckDirty() git status error") repo.NoteChange("git status is in error " + fmt.Sprint(r.Error)) repo.Dirty = true - repo.State = "dirty" + repo.State = "dirty porcelain" return true } + if len(r.Stdout) == 0 { + repo.Dirty = false + repo.SmartSetState("") + } // dirty if anything but go.mod and go.sum var bad bool = false for _, line := range r.Stdout { @@ -68,9 +72,11 @@ func (repo *Repo) CheckDirty() bool { repo.Times.LastDirty = pbnow repo.Dirty = bad if bad { - return repo.SmartSetState("dirty") - } else { - return repo.SmartSetState("") + repo.Dirty = true + repo.SmartSetState("dirty") + return true } - return bad + repo.Dirty = false + repo.SmartSetState("") + return false } |
