repostatus/update.go

58 lines
1.2 KiB
Go

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 () {
rs.path.Set(rs.repopath)
rs.getCurrentBranchName()
rs.window.Title(rs.repopath + " GO repo Details")
rs.getCurrentBranchVersion()
rs.getLastTagVersion()
rs.populateTags()
// 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.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")
}
}