summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-14 11:28:15 -0600
committerJeff Carr <[email protected]>2024-12-14 11:28:15 -0600
commitb1d6923ca2b69b90e1edfe011a12f3fef5d1fa2e (patch)
treea4f4ff82c70f4b78df4d8930243b54d571a82765
parentd20ce6b0e8153f41421b6c245a8a5ab5aac079f7 (diff)
add InitPB() for read-only init()
-rw-r--r--human.go12
-rw-r--r--init.go40
2 files changed, 24 insertions, 28 deletions
diff --git a/human.go b/human.go
index 1d6a9c5..06caa9a 100644
--- a/human.go
+++ b/human.go
@@ -2,7 +2,6 @@ package forgepb
import (
"fmt"
- "time"
"go.wit.com/lib/gui/shell"
"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
func (f *Forge) StandardReleaseHeader(repo *gitpb.Repo, state string) string {
lastTag := repo.GetLastTag()
// tag := repo.NewestTag()
// gitAge, _ := tag.GetDate()
- dur := f.NewestAge(repo)
+ dur := repo.NewestAge()
curname := repo.GetCurrentBranchName()
master := repo.GetMasterVersion()
diff --git a/init.go b/init.go
index 6b7c420..76df111 100644
--- a/init.go
+++ b/init.go
@@ -13,6 +13,29 @@ import (
// cache.go has Do()
// f.initOnce.Do(f.initWork)
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)
// TODO: rethink this but it works for now
@@ -56,22 +79,5 @@ func Init() *Forge {
}
f.Repos = new(gitpb.Repos)
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
}