summaryrefslogtreecommitdiff
path: root/update.go
blob: 55d529f55863c0a25de40e01e1d8c482dadc70fb (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 (
	"errors"

	"go.wit.com/log"
)

func (rs *RepoStatus) UpdateNew() {
	log.Info("gui update", rs.pb.GetFullPath())
	rs.updateNew()
}

func (rs *RepoStatus) updateNew() {
	if !rs.Ready() {
		log.Log(WARN, "can't update yet. ready is false")
		log.Error(errors.New("Update() is not ready yet"))
		return
	}

	pb := rs.pb

	// store the current checked out branch name and version
	rs.checkCurrentBranchName()
	rs.checkCurrentBranchVersion()

	// read in the tags
	rs.populateTags()

	// record if the repo is dirty
	pb.CheckDirty()

	// store the last tag version
	rs.setLastTagVersion()

	// store the master branch version
	ver := pb.GetMasterVersion()
	rs.mainBranchVersion.SetValue(ver)

	rs.develBranchVersion.SetValue(pb.GetDevelVersion())
	rs.userBranchVersion.SetValue(pb.GetUserVersion())

	// populates a string into the rs.gitState widget
	// todo: make the values from this function a bit cleaner
	rs.CheckGitState()
}

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(INFO, "Update() START")
	rs.updateNew()
	log.Log(INFO, "Update() END")
}