summaryrefslogtreecommitdiff
path: root/scan.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-17 08:39:55 -0600
committerJeff Carr <[email protected]>2024-02-17 08:39:55 -0600
commit1b103f2a1c9beb87e61ebbd04fe7cdbf605988ed (patch)
tree4cf62152850f85474118d9d7e61f0de7f1ffbbdf /scan.go
initial importv0.0.1
Diffstat (limited to 'scan.go')
-rw-r--r--scan.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/scan.go b/scan.go
new file mode 100644
index 0000000..8f36f1b
--- /dev/null
+++ b/scan.go
@@ -0,0 +1,75 @@
+package repolist
+
+import (
+ "fmt"
+ "os/user"
+ "strings"
+
+ "go.wit.com/log"
+)
+
+func ScanRepositories() (int, string) {
+ var i int
+ t := timeFunction(func() {
+ for _, repo := range me.allrepos {
+ i += 1
+ repo.newScan()
+ }
+ })
+ s := fmt.Sprint(t)
+ log.Info("Scanned", i, "repositories. todo: count/show changes", s)
+ return i, s
+}
+
+func (r *Repo) newScan() bool {
+ if r.status == nil {
+ log.Warn("repo.status = nil. not initialized for some reason")
+ 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)
+
+ dname := r.status.GetDevelBranchName()
+ dver := r.status.GetDevelVersion()
+ if dname != "devel" {
+ dver = dver + " (" + dname + ")"
+ }
+ r.develVersion.SetLabel(dver)
+
+ uname := r.status.GetUserBranchName()
+ uver := r.status.GetUserVersion()
+ usr, _ := user.Current()
+ if uname != usr.Username {
+ uver = uver + " (" + uname + ")"
+ }
+ r.userVersion.SetLabel(uver)
+
+ cbname := r.status.GetCurrentBranchName()
+ cbversion := r.status.GetCurrentBranchVersion()
+ lasttag := r.status.GetLastTagVersion()
+ r.lastTag.SetLabel(lasttag)
+ r.vLabel.SetLabel(cbname + " " + cbversion)
+
+ 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)
+ if status == "PERFECT" {
+ if me.autoHidePerfect {
+ r.Hide()
+ }
+ return true
+ }
+ return false
+}