allow more fields to be mirrored

This commit is contained in:
Jeff Carr 2024-02-19 16:29:10 -06:00
parent ad21d5d5db
commit ae7e9ba42c
5 changed files with 53 additions and 40 deletions

View File

@ -192,3 +192,23 @@ func (rs *RepoStatus) MirrorCurrentVersion() *gui.Node {
func (rs *RepoStatus) MirrorCurrentName() *gui.Node { func (rs *RepoStatus) MirrorCurrentName() *gui.Node {
return rs.currentBranch.MirrorValue() 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()
}

View File

@ -25,6 +25,7 @@ func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
rs.userWorkingName.SetValue("uid") rs.userWorkingName.SetValue("uid")
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty") rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
rs.gitState = gadgets.NewOneLiner(newgrid, "git state")
rs.readOnly = gadgets.NewOneLiner(newgrid, "read only") rs.readOnly = gadgets.NewOneLiner(newgrid, "read only")
rs.goSumStatus = gadgets.NewOneLiner(newgrid, "go mod status") rs.goSumStatus = gadgets.NewOneLiner(newgrid, "go mod status")
rs.targetReleaseVersion = gadgets.NewOneLiner(newgrid, "target release version") rs.targetReleaseVersion = gadgets.NewOneLiner(newgrid, "target release version")

30
git.go
View File

@ -408,28 +408,46 @@ func (rs *RepoStatus) setUserVersion(s string) {
rs.userBranchVersion.SetValue(s) 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 { func (rs *RepoStatus) GetStatus() string {
return rs.gitState.String()
}
func (rs *RepoStatus) setState() {
rs.changed = false rs.changed = false
if rs.CheckDirty() { if rs.CheckDirty() {
log.Log(INFO, "CheckDirty() true") log.Log(INFO, "CheckDirty() true")
return "dirty" rs.gitState.SetText("dirty")
return
} }
if rs.GetUserVersion() != rs.GetDevelVersion() { if rs.GetUserVersion() != rs.GetDevelVersion() {
return "merge to devel" rs.gitState.SetText("merge to devel")
return
} }
if rs.GetDevelVersion() != rs.GetMasterVersion() { if rs.GetDevelVersion() != rs.GetMasterVersion() {
return "merge to main" rs.gitState.SetText("merge to main")
return
} }
if rs.lasttag.String() != rs.GetMasterVersion() { if rs.lasttag.String() != rs.GetMasterVersion() {
return "unchanged" rs.gitState.SetText("unchanged")
return
} }
if rs.CheckBranches() { if rs.CheckBranches() {
log.Log(INFO, "Branches are Perfect") log.Log(INFO, "Branches are Perfect")
return "PERFECT" rs.gitState.SetText("PERFECT")
return
} }
log.Log(INFO, rs.String(), "Branches are not Perfect") log.Log(INFO, rs.String(), "Branches are not Perfect")
return "unknown branches" rs.gitState.SetText("unknown branches")
} }
// TODO: make this report the error somewhere // TODO: make this report the error somewhere

View File

@ -25,6 +25,7 @@ type RepoStatus struct {
dirtyLabel *gadgets.OneLiner dirtyLabel *gadgets.OneLiner
readOnly *gadgets.OneLiner readOnly *gadgets.OneLiner
goSumStatus *gadgets.OneLiner goSumStatus *gadgets.OneLiner
gitState *gadgets.OneLiner
path *gadgets.OneLiner path *gadgets.OneLiner
goSrcPath *gadgets.OneLiner goSrcPath *gadgets.OneLiner

View File

@ -65,11 +65,13 @@ func (rs *RepoStatus) UpdateNew() {
out, _ = rs.gitDescribeByName(uName) out, _ = rs.gitDescribeByName(uName)
rs.setUserVersion(out) rs.setUserVersion(out)
} }
// populates a string into the rs.gitState widget
// todo: make the values from this function a bit cleaner
rs.CheckGitState()
} }
/* func (rs *RepoStatus) Update() {
// deprecate / redo what is left of this
func (rs *RepoStatus) UpdateOld() {
if !rs.Ready() { if !rs.Ready() {
log.Log(WARN, "can't update yet. ready is false") log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet")) log.Error(errors.New("Update() is not ready yet"))
@ -78,39 +80,10 @@ func (rs *RepoStatus) UpdateOld() {
log.Log(INFO, "Update() START") log.Log(INFO, "Update() START")
duration := timeFunction(func() { duration := timeFunction(func() {
rs.UpdateNew() 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) rs.setSpeed(duration)
log.Log(INFO, "Update() END") log.Log(INFO, "Update() END")
} }
*/
func (rs *RepoStatus) setSpeed(duration time.Duration) { func (rs *RepoStatus) setSpeed(duration time.Duration) {
s := fmt.Sprint(duration) s := fmt.Sprint(duration)
@ -120,9 +93,9 @@ func (rs *RepoStatus) setSpeed(duration time.Duration) {
} }
rs.speedActual.SetValue(s) rs.speedActual.SetValue(s)
if duration > 500*time.Millisecond { if duration > 200*time.Millisecond {
rs.speed.SetValue("SLOW") rs.speed.SetValue("SLOW")
} else if duration > 100*time.Millisecond { } else if duration > 50*time.Millisecond {
rs.speed.SetValue("OK") rs.speed.SetValue("OK")
} else { } else {
rs.speed.SetValue("FAST") rs.speed.SetValue("FAST")