summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-19 16:29:10 -0600
committerJeff Carr <[email protected]>2024-02-19 16:29:10 -0600
commitae7e9ba42c44687db038cacf7e0ae845e497f6e0 (patch)
treefe79e556726dd89e9aa21a2fb245b1d5c53579e8
parentad21d5d5db43b975e88067ff730691e89e10ea97 (diff)
allow more fields to be mirrored
-rw-r--r--common.go20
-rw-r--r--draw.go1
-rw-r--r--git.go30
-rw-r--r--structs.go1
-rw-r--r--update.go41
5 files changed, 53 insertions, 40 deletions
diff --git a/common.go b/common.go
index dca7126..a2c8685 100644
--- a/common.go
+++ b/common.go
@@ -192,3 +192,23 @@ func (rs *RepoStatus) MirrorCurrentVersion() *gui.Node {
func (rs *RepoStatus) MirrorCurrentName() *gui.Node {
return rs.currentBranch.MirrorValue()
}
+
+func (rs *RepoStatus) MirrorGitState() *gui.Node {
+ return rs.gitState.MirrorValue()
+}
+
+func (rs *RepoStatus) MirrorGoState() *gui.Node {
+ return rs.goSumStatus.MirrorValue()
+}
+
+func (rs *RepoStatus) MirrorMasterVersion() *gui.Node {
+ return rs.mainBranchVersion.MirrorValue()
+}
+
+func (rs *RepoStatus) MirrorDevelVersion() *gui.Node {
+ return rs.develBranchVersion.MirrorValue()
+}
+
+func (rs *RepoStatus) MirrorUserVersion() *gui.Node {
+ return rs.userBranchVersion.MirrorValue()
+}
diff --git a/draw.go b/draw.go
index 814e92b..b632df7 100644
--- a/draw.go
+++ b/draw.go
@@ -25,6 +25,7 @@ func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
rs.userWorkingName.SetValue("uid")
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
+ rs.gitState = gadgets.NewOneLiner(newgrid, "git state")
rs.readOnly = gadgets.NewOneLiner(newgrid, "read only")
rs.goSumStatus = gadgets.NewOneLiner(newgrid, "go mod status")
rs.targetReleaseVersion = gadgets.NewOneLiner(newgrid, "target release version")
diff --git a/git.go b/git.go
index 690412f..0bd8c1b 100644
--- a/git.go
+++ b/git.go
@@ -408,28 +408,46 @@ func (rs *RepoStatus) setUserVersion(s string) {
rs.userBranchVersion.SetValue(s)
}
+func (rs *RepoStatus) GitState() string {
+ return rs.gitState.String()
+}
+
+func (rs *RepoStatus) CheckGitState() string {
+ rs.setState()
+ return rs.gitState.String()
+}
+
func (rs *RepoStatus) GetStatus() string {
+ return rs.gitState.String()
+}
+
+func (rs *RepoStatus) setState() {
rs.changed = false
if rs.CheckDirty() {
log.Log(INFO, "CheckDirty() true")
- return "dirty"
+ rs.gitState.SetText("dirty")
+ return
}
if rs.GetUserVersion() != rs.GetDevelVersion() {
- return "merge to devel"
+ rs.gitState.SetText("merge to devel")
+ return
}
if rs.GetDevelVersion() != rs.GetMasterVersion() {
- return "merge to main"
+ rs.gitState.SetText("merge to main")
+ return
}
if rs.lasttag.String() != rs.GetMasterVersion() {
- return "unchanged"
+ rs.gitState.SetText("unchanged")
+ return
}
if rs.CheckBranches() {
log.Log(INFO, "Branches are Perfect")
- return "PERFECT"
+ rs.gitState.SetText("PERFECT")
+ return
}
log.Log(INFO, rs.String(), "Branches are not Perfect")
- return "unknown branches"
+ rs.gitState.SetText("unknown branches")
}
// TODO: make this report the error somewhere
diff --git a/structs.go b/structs.go
index a5eb104..869a9f8 100644
--- a/structs.go
+++ b/structs.go
@@ -25,6 +25,7 @@ type RepoStatus struct {
dirtyLabel *gadgets.OneLiner
readOnly *gadgets.OneLiner
goSumStatus *gadgets.OneLiner
+ gitState *gadgets.OneLiner
path *gadgets.OneLiner
goSrcPath *gadgets.OneLiner
diff --git a/update.go b/update.go
index 8e60e8c..02b5806 100644
--- a/update.go
+++ b/update.go
@@ -65,11 +65,13 @@ func (rs *RepoStatus) UpdateNew() {
out, _ = rs.gitDescribeByName(uName)
rs.setUserVersion(out)
}
+
+ // populates a string into the rs.gitState widget
+ // todo: make the values from this function a bit cleaner
+ rs.CheckGitState()
}
-/*
-// deprecate / redo what is left of this
-func (rs *RepoStatus) UpdateOld() {
+func (rs *RepoStatus) Update() {
if !rs.Ready() {
log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet"))
@@ -78,39 +80,10 @@ func (rs *RepoStatus) UpdateOld() {
log.Log(INFO, "Update() START")
duration := timeFunction(func() {
rs.UpdateNew()
-
- if rs.dirtyLabel.String() != "no" {
- log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String())
- rs.DisableEverything()
- rs.CheckBranches()
- return
- }
-
- master := rs.mainWorkingName.String()
- devel := rs.develWorkingName.String()
- user := rs.userWorkingName.String()
-
- // rs.CheckDirty() this runs
- log.Log(INFO, "checkoutBranch", master)
- rs.checkoutBranch("master", master)
- log.Log(INFO, "checkoutBranch", devel)
- rs.checkoutBranch("devel", devel)
- log.Log(INFO, "checkoutBranch", user)
- rs.checkoutBranch("user", user)
-
- rs.recommend()
- rs.CheckBranches()
-
- label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
- rs.develMergeB.SetLabel(label)
-
- label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
- rs.mainMergeB.SetLabel(label)
})
rs.setSpeed(duration)
log.Log(INFO, "Update() END")
}
-*/
func (rs *RepoStatus) setSpeed(duration time.Duration) {
s := fmt.Sprint(duration)
@@ -120,9 +93,9 @@ func (rs *RepoStatus) setSpeed(duration time.Duration) {
}
rs.speedActual.SetValue(s)
- if duration > 500*time.Millisecond {
+ if duration > 200*time.Millisecond {
rs.speed.SetValue("SLOW")
- } else if duration > 100*time.Millisecond {
+ } else if duration > 50*time.Millisecond {
rs.speed.SetValue("OK")
} else {
rs.speed.SetValue("FAST")