2024-01-09 15:34:53 -06:00
|
|
|
package repostatus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
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"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Log(WARN, "Update() START")
|
|
|
|
duration := timeFunction(func () {
|
2024-01-10 18:18:01 -06:00
|
|
|
// do things that are safe even if the git tree is dirty
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("path.Set()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.path.Set(rs.repopath)
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("getCurrentBranchName()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.getCurrentBranchName()
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("set window Title()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.window.Title(rs.repopath + " GO repo Details")
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("getCurrentBranchVersion()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.getCurrentBranchVersion()
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("getLastTagVersion()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.getLastTagVersion()
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("populateTags()")
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.populateTags()
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("checkDirty()")
|
|
|
|
rs.checkDirty()
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-01-10 19:44:10 -06:00
|
|
|
if rs.dirtyLabel.Get() != "no" {
|
|
|
|
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get())
|
|
|
|
rs.DisableEverything()
|
|
|
|
return
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
2024-01-10 19:44:10 -06:00
|
|
|
|
|
|
|
// rs.checkDirty() this runs
|
|
|
|
log.Log(WARN, "")
|
|
|
|
log.Log(WARN, "checkoutBranch master")
|
|
|
|
rs.checkoutBranch("master")
|
|
|
|
log.Log(WARN, "")
|
|
|
|
log.Log(WARN, "checkoutBranch devel")
|
|
|
|
rs.checkoutBranch("devel")
|
|
|
|
log.Log(WARN, "")
|
|
|
|
log.Log(WARN, "checkoutBranch jcarr")
|
|
|
|
rs.checkoutBranch("jcarr")
|
|
|
|
|
|
|
|
rs.recommend()
|
2024-01-09 15:34:53 -06:00
|
|
|
})
|
|
|
|
rs.setSpeed(duration)
|
|
|
|
log.Log(WARN, "Update() END")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) setSpeed(duration time.Duration) {
|
|
|
|
s := fmt.Sprint(duration)
|
|
|
|
if rs.speedActual == nil {
|
|
|
|
log.Log(WARN, "can't actually warn")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
rs.speedActual.Set(s)
|
|
|
|
|
|
|
|
if (duration > 500 * time.Millisecond ) {
|
|
|
|
rs.speed.Set("SLOW")
|
|
|
|
} else if (duration > 100 * time.Millisecond ) {
|
|
|
|
rs.speed.Set("OK")
|
|
|
|
} else {
|
|
|
|
rs.speed.Set("FAST")
|
|
|
|
}
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
// disable all things besides Update() button
|
|
|
|
func (rs *RepoStatus) DisableEverything() {
|
2024-01-10 19:44:10 -06:00
|
|
|
log.Warn("DisableEverything()")
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
// choosing a major, minor or revision
|
|
|
|
rs.major.Disable()
|
|
|
|
rs.minor.Disable()
|
|
|
|
rs.revision.Disable()
|
|
|
|
|
|
|
|
// disable adding a tag message
|
|
|
|
rs.versionMessage.Disable()
|
|
|
|
|
|
|
|
// disable the merge devel to master button
|
|
|
|
rs.develMerge.Disable()
|
|
|
|
|
|
|
|
// disable the tag a new version button
|
|
|
|
rs.releaseVersion.Disable()
|
|
|
|
}
|
|
|
|
|
|
|
|
// this means devel needs to be merged to master
|
|
|
|
func (rs *RepoStatus) EnableMergeDevel() {
|
|
|
|
rs.DisableEverything()
|
|
|
|
|
|
|
|
rs.develMerge.Enable()
|
|
|
|
}
|
|
|
|
|
|
|
|
// this means you need to release a new version of the master repository
|
|
|
|
func (rs *RepoStatus) EnableSelectTag() {
|
|
|
|
rs.DisableEverything()
|
|
|
|
|
|
|
|
// choosing a major, minor or revision
|
|
|
|
rs.major.Enable()
|
|
|
|
rs.minor.Enable()
|
|
|
|
rs.revision.Enable()
|
|
|
|
|
|
|
|
// disable adding a tag message
|
|
|
|
rs.versionMessage.Enable()
|
|
|
|
|
|
|
|
// force there to be a commit message
|
|
|
|
rs.releaseVersion.Disable()
|
|
|
|
}
|