From 0d01d8276659a0ed56827f23e41fc0b0a7304f83 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 9 Jan 2024 09:56:33 -0600 Subject: [PATCH] gets jcarr,devel and master branch info Signed-off-by: Jeff Carr --- git.go | 26 +++++++++++++++++++------- main.go | 28 +++++++++++++++++++++------- unix.go | 8 ++++++-- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/git.go b/git.go index bc7b283..75f4618 100644 --- a/git.go +++ b/git.go @@ -12,12 +12,24 @@ import ( ) func (r *repo) checkoutBranch(branch string) { - if ! r.checkDirty() { - out := run(r.path, "git", "checkout " + branch) - log.Warn(r.path, "git checkout " + branch, "returned", out) + 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 } diff --git a/main.go b/main.go index 953294e..511d40c 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/unix.go b/unix.go index 94a722f..cbf6b28 100644 --- a/unix.go +++ b/unix.go @@ -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 {