summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-17 14:21:05 -0600
committerJeff Carr <[email protected]>2024-02-17 14:21:05 -0600
commitbbc78159fe11c78ae33cc8026887f62888003630 (patch)
treed103c28bba28cd5e1a981c6a13f225c59644242b
parent6b5472ea43826bf1fce95257ffe51560ef3e0f04 (diff)
using repolist
-rw-r--r--doRelease.go2
-rw-r--r--main.go15
-rw-r--r--repolist.go18
-rw-r--r--scan.go126
-rw-r--r--scanGoSum.go92
5 files changed, 140 insertions, 113 deletions
diff --git a/doRelease.go b/doRelease.go
index d339186..2d2b9d1 100644
--- a/doRelease.go
+++ b/doRelease.go
@@ -111,7 +111,7 @@ func doRelease() bool {
log.Info("EVERYTHING OK. RERELEASED", release.current.String())
// update the package versions used for checking go.sum validity
- release.current.status.UpdateCurrent()
+ release.current.status.UpdateNew()
cbname := release.current.status.GetCurrentBranchName()
cbversion := release.current.status.GetCurrentBranchVersion()
lasttag := release.current.status.GetLastTagVersion()
diff --git a/main.go b/main.go
index 0279876..3f6be1e 100644
--- a/main.go
+++ b/main.go
@@ -63,8 +63,19 @@ func main() {
me.releaseReasonS = releaseReasonS
- for _, repo := range me.allrepos {
- repo.status.UpdateCurrent()
+ for i, repo := range me.allrepos {
+ if repo == nil {
+ log.Info("initial scan i = nil", i)
+ continue
+ }
+
+ log.Info("initial scan repo", repo.String())
+ if repo.status == nil {
+ log.Info("repo.status == nil", repo.String())
+ continue
+ }
+
+ repo.status.UpdateNew()
repo.newScan()
if repo.String() == "go.wit.com/widget" {
diff --git a/repolist.go b/repolist.go
index 2f2e354..da0adbf 100644
--- a/repolist.go
+++ b/repolist.go
@@ -13,6 +13,9 @@ import (
)
func (r *repo) String() string {
+ if r.status == nil {
+ return r.path
+ }
return r.status.String()
}
@@ -129,19 +132,11 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo := new(repo)
- path = strings.Trim(path, "/") // trim any extranous '/' chars put in the config file by the user
if path == "" {
log.Warn("addRepo() got empty path", path, master, devel, user)
return
}
- if repostatus.VerifyLocalGoRepo(path) {
- log.Verbose("newRepo actually exists", newRepo.getPath())
- } else {
- log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path, master, devel, user)
- return
- }
-
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
@@ -163,9 +158,10 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
})
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
+ if newRepo.status == nil {
+ log.Warn("something is wrong with", path)
+ os.Exit(0)
+ }
newRepo.hidden = false
- newRepo.status.SetMainWorkingName(master)
- newRepo.status.SetDevelWorkingName(devel)
- newRepo.status.SetUserWorkingName(user)
me.allrepos[path] = newRepo
}
diff --git a/scan.go b/scan.go
index 2d2f78f..5945ece 100644
--- a/scan.go
+++ b/scan.go
@@ -1,27 +1,39 @@
-// This is a simple example
package main
import (
"fmt"
+ "strings"
"time"
"go.wit.com/log"
-
- "go.wit.com/lib/gui/repostatus"
)
+func scanRepositories() {
+ var i int = 0
+ t := timeFunction(func() {
+ for _, repo := range me.allrepos {
+ repo.newScan()
+ i += 1
+ }
+ })
+ s := fmt.Sprint(t)
+ log.Info("Scanned", i, "repositories. todo: count/show changes", s)
+}
+
func (r *repo) newScan() bool {
if r.status == nil {
log.Warn("repo.status = nil. not initialized for some reason")
return false
}
- // r.scan()
- if repostatus.VerifyLocalGoRepo(r.getPath()) {
- log.Verbose("repo actually exists", r.getPath())
- } else {
- log.Warn("repo does not exist", r.getPath())
- return false
- }
+
+ // first run the repostatus update
+ r.status.UpdateNew()
+
+ // now read those values and display them in our table
+ // mname := r.status.GetMasterBranchName()
+ // mver := r.status.GetMasterVersion()
+ // mver = mver + " (" + mname + ")"
+ // r.masterVersion.SetLabel(mver)
cbname := r.status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion()
@@ -29,8 +41,11 @@ func (r *repo) newScan() bool {
r.lastTag.SetLabel(lasttag)
r.vLabel.SetLabel(cbname + " " + cbversion)
- if r.status.Changed() {
- log.Warn("should scan here")
+ if c, ok := r.status.Changed(); ok {
+ c := strings.TrimSpace(c)
+ for _, line := range strings.Split(c, "\n") {
+ log.Info(r.status.Path(), line)
+ }
}
status := r.status.GetStatus()
r.dirtyLabel.SetLabel(status)
@@ -43,93 +58,6 @@ func (r *repo) newScan() bool {
return false
}
-func (r *repo) getGoSumStatus() string {
- return r.goSumStatus.String()
-}
-
-func (r *repo) setGoSumStatus(s string) {
- r.goSumStatus.SetLabel(s)
- r.status.SetGoSumStatus(s)
-}
-
-func (r *repo) checkDirty() bool {
- if r.status.CheckDirty() {
- log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
- r.setGoSumStatus("DIRTY")
- return true
- }
- return false
-}
-
-func (r *repo) checkSafeGoSumRemake() {
- if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
- log.Info("checkSafeGoSumRemake() is safe to redo")
- r.setGoSumStatus("SAFE")
- r.status.MakeRedomod()
- } else {
- log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
- r.setGoSumStatus("BAD DEP")
- }
-}
-
-func scanGoSum() {
- for _, repo := range me.allrepos {
- if repo.String() == "go.wit.com/apps/guireleaser" {
- if release.guireleaser == nil {
- release.guireleaser = repo
- }
- }
- latestversion := repo.status.GetLastTagVersion()
- if repo.getGoSumStatus() == "BAD" {
- continue
- }
- if repo.getGoSumStatus() == "DIRTY" {
- continue
- }
- if repo.status.CheckPrimativeGoMod() {
- log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
- repo.setGoSumStatus("PRIMATIVE")
- continue
- }
- if repo.checkDirty() {
- log.Info("dirty repo:", latestversion, repo.status.String())
- log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
- repo.setGoSumStatus("DIRTY")
-
- // release.repo.SetValue(repo.status.String())
- // release.status.SetValue("dirty")
- // release.notes.SetValue("You must commit your changes\nbefore you can continue")
- // release.current = repo
- // release.openrepo.Enable()
- continue
- }
- if ok, missing := repo.status.CheckGoSum(); ok {
- log.Info("repo has go.sum requirements that are clean")
- repo.setGoSumStatus("CLEAN")
- } else {
- log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
- repo.setGoSumStatus("BAD")
-
- // release.repo.SetValue(repo.status.String())
- // release.status.SetValue("bad")
- // release.notes.SetValue("the go.sum file is wrong")
- // release.current = repo
- // release.openrepo.Enable()
- continue
- }
- status := repo.dirtyLabel.String()
- if status == "PERFECT" {
- continue
- } else {
- repo.status.UpdateCurrent()
- repo.newScan()
- }
-
- log.Info("repo:", latestversion, status, repo.status.String())
- }
- log.Info("scanGoSum() did everything, not sure what to do next")
-}
-
// timeFunction takes a function as an argument and returns the execution time.
func timeFunction(f func()) time.Duration {
startTime := time.Now() // Record the start time
diff --git a/scanGoSum.go b/scanGoSum.go
new file mode 100644
index 0000000..8701808
--- /dev/null
+++ b/scanGoSum.go
@@ -0,0 +1,92 @@
+// This is a simple example
+package main
+
+import (
+ "go.wit.com/log"
+)
+
+func (r *repo) getGoSumStatus() string {
+ return r.goSumStatus.String()
+}
+
+func (r *repo) setGoSumStatus(s string) {
+ r.goSumStatus.SetLabel(s)
+ r.status.SetGoSumStatus(s)
+}
+
+func (r *repo) checkDirty() bool {
+ if r.status.CheckDirty() {
+ log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
+ r.setGoSumStatus("DIRTY")
+ return true
+ }
+ return false
+}
+
+func (r *repo) checkSafeGoSumRemake() {
+ if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
+ log.Info("checkSafeGoSumRemake() is safe to redo")
+ r.setGoSumStatus("SAFE")
+ r.status.MakeRedomod()
+ } else {
+ log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
+ r.setGoSumStatus("BAD DEP")
+ }
+}
+
+func scanGoSum() {
+ for _, repo := range me.allrepos {
+ if repo.String() == "go.wit.com/apps/guireleaser" {
+ if release.guireleaser == nil {
+ release.guireleaser = repo
+ }
+ }
+ latestversion := repo.status.GetLastTagVersion()
+ if repo.getGoSumStatus() == "BAD" {
+ continue
+ }
+ if repo.getGoSumStatus() == "DIRTY" {
+ continue
+ }
+ if repo.status.CheckPrimativeGoMod() {
+ log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
+ repo.setGoSumStatus("PRIMATIVE")
+ continue
+ }
+ if repo.checkDirty() {
+ log.Info("dirty repo:", latestversion, repo.status.String())
+ log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
+ repo.setGoSumStatus("DIRTY")
+
+ // release.repo.SetValue(repo.status.String())
+ // release.status.SetValue("dirty")
+ // release.notes.SetValue("You must commit your changes\nbefore you can continue")
+ // release.current = repo
+ // release.openrepo.Enable()
+ continue
+ }
+ if ok, missing := repo.status.CheckGoSum(); ok {
+ log.Info("repo has go.sum requirements that are clean")
+ repo.setGoSumStatus("CLEAN")
+ } else {
+ log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
+ repo.setGoSumStatus("BAD")
+
+ // release.repo.SetValue(repo.status.String())
+ // release.status.SetValue("bad")
+ // release.notes.SetValue("the go.sum file is wrong")
+ // release.current = repo
+ // release.openrepo.Enable()
+ continue
+ }
+ status := repo.dirtyLabel.String()
+ if status == "PERFECT" {
+ continue
+ } else {
+ repo.newScan()
+ }
+
+ log.Info("repo:", latestversion, status, repo.status.String())
+ }
+ log.Info("scanGoSum() did everything, not sure what to do next")
+}