73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
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()
|
|
if argv.Verbose {
|
|
me.forge.PrintHumanTableDirty(me.found)
|
|
} else {
|
|
me.forge.PrintHumanTable(me.found)
|
|
}
|
|
}
|
|
|
|
func straightCheckDirty() int {
|
|
var count int
|
|
// var total int
|
|
// now := time.Now()
|
|
all := me.found.All()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
// total += 1
|
|
if repo.IsDirty() {
|
|
count += 1
|
|
}
|
|
}
|
|
// log.Printf("rill dirty check (%d dirty repos) (%d total repos) took:%s\n", count, total, shell.FormatDuration(time.Since(now)))
|
|
return count
|
|
}
|
|
|
|
func doCheckDirty(repo *gitpb.Repo) error {
|
|
repo.CheckDirty()
|
|
// reset these in here for now
|
|
if repo.GetTargetVersion() != "" {
|
|
repo.TargetVersion = ""
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func doCheckDirtyAndConfigSave() {
|
|
start := straightCheckDirty()
|
|
// log.Info("before findAll()")
|
|
/*
|
|
all := me.found.All()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
repo.CheckDirty()
|
|
}
|
|
*/
|
|
// this might work?
|
|
now := time.Now()
|
|
me.forge.RillFuncError(doCheckDirty)
|
|
end := straightCheckDirty()
|
|
log.Printf("dirty check (%d dirty repos) (%d total repos) took:%s\n", end, me.found.Len(), shell.FormatDuration(time.Since(now)))
|
|
|
|
if start != end {
|
|
// todo: use internal forgepb configsave flag. should work?
|
|
me.forge.SetConfigSave(true)
|
|
me.forge.ConfigSave()
|
|
}
|
|
}
|