forge/doDirty.go

61 lines
1.2 KiB
Go
Raw Normal View History

2025-01-17 10:59:05 -06:00
package main
import (
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
func doDirty() {
findAll() // select all the repos
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
me.forge.PrintHumanTableDirty(me.found)
}
2025-01-18 10:34:13 -06:00
func straightCheckDirty() int {
2025-01-17 10:59:05 -06:00
var count int
2025-01-18 10:34:13 -06:00
var total int
2025-01-17 10:59:05 -06:00
now := time.Now()
2025-01-18 10:34:13 -06:00
all := me.found.All()
2025-01-17 10:59:05 -06:00
for all.Scan() {
repo := all.Next()
2025-01-18 10:34:13 -06:00
total += 1
if repo.IsDirty() {
2025-01-17 10:59:05 -06:00
count += 1
}
}
2025-01-18 10:34:13 -06:00
log.Printf("rill dirty check (%d dirty repos) (%d total repos) took:%s\n", count, total, shell.FormatDuration(time.Since(now)))
return count
}
2025-01-18 11:10:53 -06:00
func doCheckDirty(repo *gitpb.Repo) error {
repo.CheckDirty()
return nil
}
2025-01-18 10:34:13 -06:00
func doCheckDirtyAndConfigSave() {
start := straightCheckDirty()
// log.Info("before findAll()")
2025-01-18 11:10:53 -06:00
/*
all := me.found.All()
for all.Scan() {
repo := all.Next()
repo.CheckDirty()
}
*/
// this might work?
now := time.Now()
2025-01-18 23:25:55 -06:00
me.forge.RillFuncError(doCheckDirty)
2025-01-18 10:34:13 -06:00
end := straightCheckDirty()
log.Printf("dirty check (%d dirty repos) (%d total repos) took:%s\n", end, me.found.Len(), shell.FormatDuration(time.Since(now)))
2025-01-18 11:10:53 -06:00
2025-01-18 10:34:13 -06:00
if start != end {
// todo: use internal forgepb configsave flag. should work?
me.forge.ConfigSave()
}
2025-01-17 10:59:05 -06:00
}