144 lines
3.1 KiB
Go
144 lines
3.1 KiB
Go
// This is a simple example
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"go.wit.com/log"
|
|
|
|
// "go.wit.com/gui/gui"
|
|
// "go.wit.com/gui/gadgets"
|
|
// "go.wit.com/apps/control-panel-dns/smartwindow"
|
|
)
|
|
|
|
func (r *repo) checkoutBranch(branch string) {
|
|
if r.checkDirty() {
|
|
return
|
|
}
|
|
out := run(r.path, "git", "checkout " + branch)
|
|
log.Warn(r.path, "git checkout " + branch, "returned", out)
|
|
|
|
realname := r.getCurrentBranchName()
|
|
realversion := r.getCurrentBranchVersion()
|
|
log.Warn(r.path, "realname =", realname, "realversion =", realversion)
|
|
if realname == "jcarr" {
|
|
r.jcarrVersion.Set(realversion)
|
|
}
|
|
if realname == "devel" {
|
|
r.develVersion.Set(realversion)
|
|
}
|
|
if realname == "master" {
|
|
r.masterVersion.Set(realversion)
|
|
}
|
|
}
|
|
|
|
func (r *repo) getBranch() {
|
|
out := run(r.path, "git", "branch --show-current")
|
|
r.bLabel.SetText(out)
|
|
}
|
|
|
|
func (r *repo) checkDirty() bool {
|
|
if r.path == "" {
|
|
log.Warn("disable spaceholders")
|
|
r.cButton.Disable()
|
|
r.pButton.Disable()
|
|
return false
|
|
}
|
|
out := run(r.path, "git", "diff-index HEAD")
|
|
if out == "" {
|
|
r.dirtyLabel.SetText("")
|
|
r.pButton.SetText("scan")
|
|
return false
|
|
} else {
|
|
r.dirtyLabel.SetText("dirty")
|
|
r.pButton.SetText("scan")
|
|
return true
|
|
}
|
|
|
|
}
|
|
|
|
func (r *repo) getLastTagVersion() string {
|
|
out := run(r.path, "git", "rev-list --tags --max-count=1")
|
|
out = strings.TrimSpace(out)
|
|
r.lasttagrev = out
|
|
|
|
lastreal := "describe --tags " + out
|
|
// out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1")
|
|
out = run(r.path, "git", lastreal)
|
|
r.lasttag = out
|
|
r.lastLabel.SetText(out)
|
|
|
|
return out
|
|
}
|
|
|
|
func (r *repo) getCurrentBranchName() string {
|
|
out := run(r.path, "git", "branch --show-current")
|
|
r.bLabel.SetText(out)
|
|
return out
|
|
}
|
|
|
|
func (r *repo) getCurrentBranchVersion() string {
|
|
out := run(r.path, "git", "describe --tags")
|
|
log.Warn("getCurrentBranchVersion", out)
|
|
r.vLabel.SetText(out)
|
|
return out
|
|
}
|
|
|
|
func (r *repo) populateTags() {
|
|
r.tags = listFiles(fullpath(r.path + "/.git/refs/tags"))
|
|
for _, tag := range r.tags {
|
|
r.tagsDrop.AddText(tag)
|
|
}
|
|
// r.tagsDrop.SetText(r.lasttag)
|
|
}
|
|
|
|
func (r *repo) scan() {
|
|
|
|
r.getLastTagVersion()
|
|
r.getCurrentBranchName()
|
|
r.getCurrentBranchVersion()
|
|
r.populateTags()
|
|
if r.checkDirty() {
|
|
return
|
|
}
|
|
r.checkoutBranch("master")
|
|
r.checkoutBranch("devel")
|
|
r.checkoutBranch("jcarr")
|
|
|
|
lasttag := r.lastLabel.GetText()
|
|
master := r.masterVersion.GetText()
|
|
devel := r.develVersion.GetText()
|
|
jcarr := r.jcarrVersion.GetText()
|
|
|
|
log.Warn("")
|
|
log.Warn("lasttag =", lasttag)
|
|
log.Warn("master =", master)
|
|
log.Warn("devel =", devel)
|
|
log.Warn("jcarr =", jcarr)
|
|
|
|
r.dirtyLabel.SetText("garbage")
|
|
|
|
if devel != master {
|
|
log.Warn("devel version != master version", devel, "vs", master)
|
|
r.dirtyLabel.SetText("merge")
|
|
return
|
|
}
|
|
if lasttag != master {
|
|
log.Warn("last tag rev != master version", lasttag, "vs", master)
|
|
r.dirtyLabel.SetText("merge")
|
|
return
|
|
}
|
|
if lasttag == jcarr {
|
|
log.Warn("last tag rev == jcarr version", lasttag, "vs", jcarr)
|
|
r.dirtyLabel.SetText("GOOD")
|
|
return
|
|
}
|
|
}
|
|
|
|
func checkrepos() {
|
|
for i, r := range allrepos {
|
|
log.Warn("scannning", i, r.path)
|
|
r.scan()
|
|
}
|
|
}
|