1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package forgepb
import (
"time"
"go.wit.com/lib/config"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"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 {
config.SetChanged("repos", true)
changed = true
}
}
if changed {
config.SetChanged("repos", true)
f.Save()
log.Printf("dirty check (%d dirty repos) (%d total repos) (%d changed) (%s)\n", end, f.Repos.Len(), diff, shell.FormatDuration(time.Since(now)))
}
}
func (f *Forge) CheckDirty() *gitpb.Repos {
start := f.straightCheckDirty()
now := time.Now()
stats := f.RillRepos(doCheckDirty)
end := f.straightCheckDirty()
diff := end - start
log.Printf("dirty check (%d dirty repos) (%d total repos) (%d changed) (%s)\n", end, f.Repos.Len(), diff, shell.FormatDuration(time.Since(now)))
for i, s := range stats {
if s.Err == nil {
} else {
log.Info(i, s.Err)
config.SetChanged("repos", true)
}
}
return f.FindDirty()
}
func (f *Forge) straightCheckDirty() int {
var count int
for repo := range f.Repos.IterAll() {
if repo.IsDirty() {
count += 1
}
}
return count
}
func doCheckDirty(repo *gitpb.Repo) error {
// reset these in here for now
if repo.GetTargetVersion() != "" {
repo.TargetVersion = ""
}
if repo.IsDirty() {
if repo.CheckDirty() {
// nothing changed
} else {
log.Info("IsDirty() said yes, then CheckDirty() immediately said no", repo.FullPath, repo.State, repo.StateChange)
return log.Errorf("%s repo changed to clean", repo.FullPath)
}
} else {
if repo.CheckDirty() {
log.Info("IsDirty() said no, then CheckDirty() immediately said yes", repo.FullPath, repo.State, repo.StateChange)
return log.Errorf("%s repo changed to dirty", repo.FullPath)
} else {
// nothing changed
}
}
return nil
}
func (f *Forge) FindDirty() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range f.Repos.IterByFullPath() {
if repo.IsDirty() {
found.AppendByFullPath(repo)
}
}
return found
}
|