82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
package repostatus
|
|
|
|
import (
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func (rs *RepoStatus) getCurrentBranchName() string {
|
|
out := run(rs.repopath, "git", "branch --show-current")
|
|
log.Warn("getCurrentBranchName() =", out)
|
|
rs.currentBranch.Set(out)
|
|
return out
|
|
}
|
|
|
|
func (rs *RepoStatus) getCurrentBranchVersion() string {
|
|
out := run(rs.repopath, "git", "describe --tags")
|
|
log.Warn("getCurrentBranchVersion()", out)
|
|
rs.currentVersion.Set(out)
|
|
return out
|
|
}
|
|
|
|
func (rs *RepoStatus) getLastTagVersion() string {
|
|
out := run(rs.repopath, "git", "rev-list --tags --max-count=1")
|
|
log.Warn("getLastTagVersion()", out)
|
|
rs.lasttagrev = out
|
|
|
|
lastreal := "describe --tags " + out
|
|
// out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1")
|
|
out = run(rs.repopath, "git", lastreal)
|
|
rs.lasttag.Set(out)
|
|
// rs.lastLabel.Set(out)
|
|
return out
|
|
}
|
|
|
|
func (rs *RepoStatus) populateTags() {
|
|
tmp := fullpath(rs.repopath + "/.git/refs/tags")
|
|
log.Warn("populateTags() path =", tmp)
|
|
for _, tag := range listFiles(tmp) {
|
|
if rs.tags[tag] == "" {
|
|
log.Warn("populateTags() Adding new tag", tag)
|
|
rs.tagsDrop.AddText(tag)
|
|
rs.tags[tag] = "origin"
|
|
}
|
|
}
|
|
rs.tagsDrop.SetText(rs.lasttagrev)
|
|
}
|
|
|
|
func (rs *RepoStatus) checkDirty() bool {
|
|
out := run(rs.repopath, "git", "diff-index HEAD")
|
|
if out == "" {
|
|
log.Warn("checkDirty() no", rs.repopath)
|
|
rs.dirtyLabel.Set("no")
|
|
return false
|
|
} else {
|
|
log.Warn("checkDirty() true", rs.repopath)
|
|
rs.dirtyLabel.Set("dirty")
|
|
return true
|
|
}
|
|
|
|
}
|
|
|
|
func (rs *RepoStatus) checkoutBranch(branch string) {
|
|
if rs.checkDirty() {
|
|
log.Warn("checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch)
|
|
return
|
|
}
|
|
out := run(rs.repopath, "git", "checkout " + branch)
|
|
log.Warn(rs.repopath, "git checkout " + branch, "returned", out)
|
|
|
|
realname := rs.getCurrentBranchName()
|
|
realversion := rs.getCurrentBranchVersion()
|
|
log.Warn(rs.repopath, "realname =", realname, "realversion =", realversion)
|
|
if realname == "jcarr" {
|
|
rs.jcarrBranch.Set(realversion)
|
|
}
|
|
if realname == "devel" {
|
|
rs.develBranch.Set(realversion)
|
|
}
|
|
if realname == "master" {
|
|
rs.masterBranch.Set(realversion)
|
|
}
|
|
}
|