gets jcarr,devel and master branch info

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-09 09:56:33 -06:00
parent 1f52d3083e
commit 0d01d82766
3 changed files with 46 additions and 16 deletions

22
git.go
View File

@ -12,12 +12,24 @@ import (
)
func (r *repo) checkoutBranch(branch string) {
if ! r.checkDirty() {
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)
}
r.getCurrentBranchName()
r.getCurrentBranchVersion()
}
func (r *repo) getBranch() {
@ -28,11 +40,11 @@ func (r *repo) getBranch() {
func (r *repo) checkDirty() bool {
out := run(r.path, "git", "diff-index HEAD")
if out == "" {
r.sLabel.SetText("")
r.dirtyLabel.SetText("")
r.pButton.Disable()
return false
} else {
r.sLabel.SetText("dirty")
r.dirtyLabel.SetText("dirty")
r.pButton.Enable()
return true
}

28
main.go
View File

@ -24,7 +24,11 @@ type repo struct {
lastLabel *gui.Node // last tagged version label
vLabel *gui.Node // version label
tagsDrop *gui.Node // list of all tags
sLabel *gui.Node // git state (dirty or not?)
dirtyLabel *gui.Node // git state (dirty or not?)
masterVersion *gui.Node // the master branch version
develVersion *gui.Node // the devel branch version
jcarrVersion *gui.Node // the jcarr branch version
cButton *gui.Node // commit button
pButton *gui.Node // push button
@ -34,6 +38,12 @@ func main() {
myGui = gui.New().Default()
helloworld()
checkrepos()
for _, r := range allrepos {
r.checkoutBranch("master")
r.checkoutBranch("devel")
r.checkoutBranch("jcarr")
}
gui.Watchdog()
}
@ -46,7 +56,11 @@ func addRepo(grid *gui.Node, path string) *repo {
newRepo.lastLabel = grid.NewLabel("")
newRepo.tagsDrop = grid.NewDropdown("tags")
newRepo.vLabel = grid.NewLabel("")
newRepo.sLabel = grid.NewLabel("")
newRepo.masterVersion = grid.NewLabel("")
newRepo.develVersion = grid.NewLabel("")
newRepo.jcarrVersion = grid.NewLabel("")
newRepo.dirtyLabel = grid.NewLabel("")
newRepo.cButton = grid.NewButton("commit", func () {
log.Println("commit")
@ -66,13 +80,16 @@ func helloworld() {
box := win.Box().NewBox("bw vbox", false)
box2 := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("test")
grid := group.NewGrid("test", 8, 1)
grid := group.NewGrid("test", 11, 1)
grid.NewLabel("go repo")
grid.NewLabel("branch")
grid.NewLabel("last tag")
grid.NewLabel("tags")
grid.NewLabel("Version")
grid.NewLabel("tags")
grid.NewLabel("master")
grid.NewLabel("devel")
grid.NewLabel("jcarr")
grid.NewLabel("is dirty?")
grid.NewLabel("commit")
grid.NewLabel("push to")
@ -90,9 +107,6 @@ func helloworld() {
addRepo(grid, "go.wit.com/gui/digitalocean")
addRepo(grid, "go.wit.com/gui/cloudflare")
box2.NewButton("checkrepos()", func () {
checkrepos()
})
box2.NewButton("checkout jcarr (all repos)", func () {
for _, r := range allrepos {
r.checkoutBranch("jcarr")

View File

@ -32,9 +32,13 @@ func run(path string, thing string, cmdline string) string {
return ""
}
tmp := string(output)
tmp = strings.TrimSpace(tmp)
// Print the output
log.Info(string(output))
return string(output)
log.Info("run()", path, thing, cmdline, "=", tmp)
return tmp
}
func listFiles(directory string) []string {