82 lines
1.9 KiB
Go
82 lines
1.9 KiB
Go
package repostatus
|
|
|
|
import (
|
|
"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
|
|
}
|
|
|
|
pb := rs.pb
|
|
|
|
// store the current checked out branch name and version
|
|
rs.checkCurrentBranchName()
|
|
out := rs.pb.GetCurrentVersion()
|
|
rs.currentVersion.SetValue(out)
|
|
|
|
// read in the tags
|
|
rs.populateTags()
|
|
|
|
// record if the repo is dirty
|
|
pb.CheckDirty()
|
|
|
|
// display the last tag version
|
|
name := rs.pb.GetLastTagVersion()
|
|
rs.lasttag.SetText(name)
|
|
|
|
// 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) CheckGitState() string {
|
|
rs.setState()
|
|
return rs.gitState.String()
|
|
}
|
|
|
|
func (rs *RepoStatus) setState() {
|
|
pb := rs.pb
|
|
rs.changed = false
|
|
if pb.CheckDirty() {
|
|
log.Log(REPO, "CheckDirty() true")
|
|
rs.gitState.SetText("dirty")
|
|
return
|
|
}
|
|
if pb.GetUserVersion() != pb.GetDevelVersion() {
|
|
rs.gitState.SetText("merge to devel")
|
|
return
|
|
}
|
|
if pb.GetDevelVersion() != pb.GetMasterVersion() {
|
|
rs.gitState.SetText("merge to main")
|
|
return
|
|
}
|
|
if pb.GetLastTag() != pb.GetMasterVersion() {
|
|
rs.gitState.SetText("unchanged")
|
|
return
|
|
}
|
|
|
|
if pb.CheckBranches() {
|
|
log.Log(REPO, "Branches are Perfect")
|
|
rs.gitState.SetText("PERFECT")
|
|
return
|
|
}
|
|
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
|
|
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
|
|
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
|
|
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
|
|
rs.gitState.SetText("unknown branches")
|
|
}
|