diff --git a/goSrcScan.go b/goSrcScan.go index f43aed1..67e6c32 100644 --- a/goSrcScan.go +++ b/goSrcScan.go @@ -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 } diff --git a/init.go b/init.go index efb2b64..4ece518 100644 --- a/init.go +++ b/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 diff --git a/structs.go b/structs.go index 7ec1abb..90b84bc 100644 --- a/structs.go +++ b/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 {