improve Init()
This commit is contained in:
parent
1369d2df31
commit
b2e51ccb9e
|
@ -163,7 +163,7 @@ func (f *Forge) RillRedoGoMod() int {
|
|||
tmp := f.Repos.SortByGoPath()
|
||||
for tmp.Scan() {
|
||||
repo := tmp.Next()
|
||||
if !repo.IsValid() {
|
||||
if !repo.IsValidDir() {
|
||||
log.Printf("%10s %-50s", "old?", repo.GetGoPath())
|
||||
continue
|
||||
}
|
||||
|
|
19
init.go
19
init.go
|
@ -34,25 +34,34 @@ func Init() *Forge {
|
|||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
||||
}
|
||||
|
||||
if f.updateAll() {
|
||||
f.updateAll()
|
||||
|
||||
if f.configSave {
|
||||
f.ConfigSave()
|
||||
f.configSave = false
|
||||
}
|
||||
log.Info("update() check took", shell.FormatDuration(time.Since(now)))
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *Forge) updateAll() bool {
|
||||
var configSave bool
|
||||
func (f *Forge) updateAll() {
|
||||
all := f.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
repo := all.Next()
|
||||
|
||||
if !repo.IsValidDir() {
|
||||
log.Printf("%10s %-50s", "old?\n", repo.GoPath)
|
||||
f.Repos.DeleteByGoPath(repo.GoPath)
|
||||
f.configSave = true
|
||||
continue
|
||||
}
|
||||
|
||||
if repo.RepoChanged() {
|
||||
configSave = true
|
||||
f.configSave = true
|
||||
log.Info("repo changed", repo.StateChange, repo.FullPath)
|
||||
repo.Reload()
|
||||
}
|
||||
}
|
||||
return configSave
|
||||
}
|
||||
|
||||
// only init's the protobuf. intended to not scan or change anything
|
||||
|
|
11
structs.go
11
structs.go
|
@ -13,11 +13,12 @@ type Forge struct {
|
|||
initOnce sync.Once
|
||||
initErr error // init error, if any
|
||||
|
||||
goSrc string // the path to go/src
|
||||
goWork bool // means the user is currently using a go.work file
|
||||
Config *ForgeConfigs // config repos for readonly, private, etc
|
||||
Repos *gitpb.Repos
|
||||
Machine *zoopb.Machine
|
||||
goSrc string // the path to go/src
|
||||
goWork bool // means the user is currently using a go.work file
|
||||
Config *ForgeConfigs // config repos for readonly, private, etc
|
||||
Repos *gitpb.Repos
|
||||
Machine *zoopb.Machine
|
||||
configSave bool
|
||||
}
|
||||
|
||||
func (f *Forge) GetGoSrc() string {
|
||||
|
|
Loading…
Reference in New Issue