save mtime's on Init()
This commit is contained in:
parent
075fce61e5
commit
1369d2df31
32
init.go
32
init.go
|
@ -3,7 +3,9 @@ package forgepb
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -15,6 +17,14 @@ import (
|
||||||
func Init() *Forge {
|
func Init() *Forge {
|
||||||
f := InitPB()
|
f := InitPB()
|
||||||
|
|
||||||
|
f.Machine = new(zoopb.Machine)
|
||||||
|
|
||||||
|
if err := f.Machine.ConfigLoad(); err != nil {
|
||||||
|
log.Warn("zoopb.ConfigLoad() failed", err)
|
||||||
|
}
|
||||||
|
f.Machine.InitWit()
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
start := f.Repos.Len()
|
start := f.Repos.Len()
|
||||||
f.ScanGoSrc()
|
f.ScanGoSrc()
|
||||||
end := f.Repos.Len()
|
end := f.Repos.Len()
|
||||||
|
@ -24,15 +34,27 @@ func Init() *Forge {
|
||||||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Machine = new(zoopb.Machine)
|
if f.updateAll() {
|
||||||
|
f.ConfigSave()
|
||||||
if err := f.Machine.ConfigLoad(); err != nil {
|
|
||||||
log.Warn("zoopb.ConfigLoad() failed", err)
|
|
||||||
}
|
}
|
||||||
f.Machine.InitWit()
|
log.Info("update() check took", shell.FormatDuration(time.Since(now)))
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Forge) updateAll() bool {
|
||||||
|
var configSave bool
|
||||||
|
all := f.Repos.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
|
||||||
|
if repo.RepoChanged() {
|
||||||
|
configSave = true
|
||||||
|
log.Info("repo changed", repo.StateChange, repo.FullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return configSave
|
||||||
|
}
|
||||||
|
|
||||||
// only init's the protobuf. intended to not scan or change anything
|
// only init's the protobuf. intended to not scan or change anything
|
||||||
func InitPB() *Forge {
|
func InitPB() *Forge {
|
||||||
f := new(Forge)
|
f := new(Forge)
|
||||||
|
|
Loading…
Reference in New Issue