126 lines
2.7 KiB
Go
126 lines
2.7 KiB
Go
package repostatus
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"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() {
|
|
// do things that are safe even if the git tree is dirty
|
|
rs.path.SetValue(rs.repopath)
|
|
rs.getCurrentBranchName()
|
|
rs.window.Title(rs.repopath + " GO repo Details")
|
|
rs.getCurrentBranchVersion()
|
|
rs.getLastTagVersion()
|
|
rs.populateTags()
|
|
rs.CheckDirty()
|
|
|
|
if rs.dirtyLabel.String() != "no" {
|
|
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String())
|
|
rs.DisableEverything()
|
|
rs.CheckBranches()
|
|
return
|
|
}
|
|
|
|
master := rs.masterDrop.String()
|
|
devel := rs.develDrop.String()
|
|
user := rs.userDrop.String()
|
|
|
|
// rs.CheckDirty() this runs
|
|
log.Log(WARN, "")
|
|
log.Log(WARN, "checkoutBranch", master)
|
|
rs.checkoutBranch("master", master)
|
|
log.Log(WARN, "")
|
|
log.Log(WARN, "checkoutBranch", devel)
|
|
rs.checkoutBranch("devel", devel)
|
|
log.Log(WARN, "")
|
|
log.Log(WARN, "checkoutBranch", user)
|
|
rs.checkoutBranch("user", user)
|
|
|
|
rs.recommend()
|
|
rs.CheckBranches()
|
|
})
|
|
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.SetValue(s)
|
|
|
|
if duration > 500*time.Millisecond {
|
|
rs.speed.SetValue("SLOW")
|
|
} else if duration > 100*time.Millisecond {
|
|
rs.speed.SetValue("OK")
|
|
} else {
|
|
rs.speed.SetValue("FAST")
|
|
}
|
|
}
|
|
|
|
// disable all things besides Update() button
|
|
func (rs *RepoStatus) DisableEverything() {
|
|
log.Warn("DisableEverything()")
|
|
|
|
// 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()
|
|
}
|
|
|
|
func (rs *RepoStatus) Disable() {
|
|
rs.window.Disable()
|
|
}
|
|
|
|
func (rs *RepoStatus) Enable() {
|
|
rs.window.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()
|
|
rs.versionMessage.SetText("")
|
|
|
|
rs.develMerge.SetLabel("ready to release")
|
|
|
|
// force there to be a commit message
|
|
rs.releaseVersion.Disable()
|
|
}
|