diff options
| author | Jeff Carr <[email protected]> | 2024-01-09 15:34:53 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-09 15:34:53 -0600 |
| commit | 87346d9452b38db517e76e070f11928060bc2b99 (patch) | |
| tree | 2e6ff93e368fda0a1581496985798fe4c1de3569 /update.go | |
initial commit
Diffstat (limited to 'update.go')
| -rw-r--r-- | update.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/update.go b/update.go new file mode 100644 index 0000000..e7544d6 --- /dev/null +++ b/update.go @@ -0,0 +1,57 @@ +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") + } +} |
