summaryrefslogtreecommitdiff
path: root/update.go
blob: e7544d6a81ac39294c76d5428ae1984efb2623f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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")
	}
}