-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
dryrun.go
46 lines (43 loc) · 1.25 KB
/
dryrun.go
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
package scanmanager
import (
"github.com/AlexAkulov/hungryfox"
"github.com/AlexAkulov/hungryfox/hercules"
)
func (sm *ScanManager) DryRun() {
total := sm.repoList.GetTotalRepos()
for i := 0; i < total; i++ {
r := sm.repoList.GetRepoByIndex(i)
if r == nil {
panic("bad index")
return
}
if err := sm.getState(r); err != nil {
sm.Log.Error().Str("error", err.Error()).
Str("data_path", r.Location.DataPath).
Str("repo_path", r.Location.RepoPath).
Str("clone_url", r.Location.CloneURL).
Bool("AllowUpdate", r.Options.AllowUpdate).
Msg("can't open repo")
continue
}
sm.Log.Debug().Int("index", i+1).Int("total", total).Str("data_path", r.Location.DataPath).Str("repo_path", r.Location.RepoPath).Msg("ok")
}
}
func (sm *ScanManager) getState(r *hungryfox.Repo) error {
r.Repo = &repo.Repo{
DiffChannel: sm.DiffChannel,
HistoryPastLimit: sm.config.Common.HistoryPastLimit,
DataPath: r.Location.DataPath,
RepoPath: r.Location.RepoPath,
URL: r.Location.URL,
CloneURL: r.Location.CloneURL,
AllowUpdate: r.Options.AllowUpdate,
}
if err := r.Repo.Open(); err != nil {
return err
}
defer r.Repo.Close()
r.State.Refs = r.Repo.GetRefs()
sm.repoList.UpdateRepo(*r)
return nil
}