add InitPB() for read-only init()
This commit is contained in:
parent
d20ce6b0e8
commit
b1d6923ca2
12
human.go
12
human.go
|
@ -2,7 +2,6 @@ package forgepb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
@ -50,21 +49,12 @@ func (f *Forge) ConfigPrintTable() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) NewestAge(repo *gitpb.Repo) time.Duration {
|
|
||||||
all := repo.Tags.SortByAge()
|
|
||||||
for all.Scan() {
|
|
||||||
r := all.Next()
|
|
||||||
return time.Since(r.GetAuthordate().AsTime())
|
|
||||||
}
|
|
||||||
return time.Since(time.Now())
|
|
||||||
}
|
|
||||||
|
|
||||||
// show information while doing golang releases
|
// show information while doing golang releases
|
||||||
func (f *Forge) StandardReleaseHeader(repo *gitpb.Repo, state string) string {
|
func (f *Forge) StandardReleaseHeader(repo *gitpb.Repo, state string) string {
|
||||||
lastTag := repo.GetLastTag()
|
lastTag := repo.GetLastTag()
|
||||||
// tag := repo.NewestTag()
|
// tag := repo.NewestTag()
|
||||||
// gitAge, _ := tag.GetDate()
|
// gitAge, _ := tag.GetDate()
|
||||||
dur := f.NewestAge(repo)
|
dur := repo.NewestAge()
|
||||||
|
|
||||||
curname := repo.GetCurrentBranchName()
|
curname := repo.GetCurrentBranchName()
|
||||||
master := repo.GetMasterVersion()
|
master := repo.GetMasterVersion()
|
||||||
|
|
40
init.go
40
init.go
|
@ -13,6 +13,29 @@ import (
|
||||||
// cache.go has Do()
|
// cache.go has Do()
|
||||||
// f.initOnce.Do(f.initWork)
|
// f.initOnce.Do(f.initWork)
|
||||||
func Init() *Forge {
|
func Init() *Forge {
|
||||||
|
f := InitPB()
|
||||||
|
|
||||||
|
start := f.Repos.Len()
|
||||||
|
f.ScanGoSrc()
|
||||||
|
end := f.Repos.Len()
|
||||||
|
if (end - start) == 0 {
|
||||||
|
log.Info("forgepb.Scan() Scan did not find new git repositories.")
|
||||||
|
} else {
|
||||||
|
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Machine = new(zoopb.Machine)
|
||||||
|
|
||||||
|
if err := f.Machine.ConfigLoad(); err != nil {
|
||||||
|
log.Warn("zoopb.ConfigLoad() failed", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
f.Machine.InitWit()
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
// only init's the protobuf. intended to not scan or change anything
|
||||||
|
func InitPB() *Forge {
|
||||||
f := new(Forge)
|
f := new(Forge)
|
||||||
|
|
||||||
// TODO: rethink this but it works for now
|
// TODO: rethink this but it works for now
|
||||||
|
@ -56,22 +79,5 @@ func Init() *Forge {
|
||||||
}
|
}
|
||||||
f.Repos = new(gitpb.Repos)
|
f.Repos = new(gitpb.Repos)
|
||||||
f.Repos.ConfigLoad()
|
f.Repos.ConfigLoad()
|
||||||
|
|
||||||
start := f.Repos.Len()
|
|
||||||
f.ScanGoSrc()
|
|
||||||
end := f.Repos.Len()
|
|
||||||
if (end - start) == 0 {
|
|
||||||
log.Info("forgepb.Scan() Scan did not find new git repositories.")
|
|
||||||
} else {
|
|
||||||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
|
||||||
}
|
|
||||||
|
|
||||||
f.Machine = new(zoopb.Machine)
|
|
||||||
|
|
||||||
if err := f.Machine.ConfigLoad(); err != nil {
|
|
||||||
log.Warn("zoopb.ConfigLoad() failed", err)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
f.Machine.InitWit()
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue