summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-09 08:35:07 -0600
committerJeff Carr <[email protected]>2024-01-09 08:35:07 -0600
commit8c999a6993d8624c2cb84b8c43bd94487d6646c5 (patch)
tree8b42057d3c178ef2b70278b8bfe7f333a1f751db
parent25c783fab563b855cd7a1218eb6751c4d2c62c49 (diff)
shows more versions
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--main.go91
1 files changed, 73 insertions, 18 deletions
diff --git a/main.go b/main.go
index 1e40608..286995d 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@
package main
import (
+ "os"
"strings"
"os/exec"
@@ -18,9 +19,13 @@ var allrepos []*repo
type repo struct {
path string
+ lasttagrev string
+ lasttag string
+ tags []string
pLabel *gui.Node // path label
bLabel *gui.Node // branch label
+ lastLabel *gui.Node // last tagged version label
vLabel *gui.Node // version label
sLabel *gui.Node // git state (dirty or not?)
@@ -39,19 +44,41 @@ func main() {
func (r *repo) scan() {
log.Info("r.path", r.path)
- b, out := run(r.path, "git", "describe --tags")
- if b {
- r.vLabel.SetText(out)
+ out := run(r.path, "git", "describe --tags")
+ r.vLabel.SetText(out)
+
+ out = run(r.path, "git", "branch --show-current")
+ r.bLabel.SetText(out)
+
+ out = run(r.path, "git", "diff-index HEAD")
+ if out == "" {
+ r.sLabel.SetText("")
+ r.pButton.Disable()
+ } else {
+ r.sLabel.SetText("dirty")
+ r.pButton.Enable()
}
+ 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)
+
+ r.tags = listFiles(fullpath(r.path + "/.git/refs/tags"))
+
// cmd := "dig +noall +answer www.wit.com A"
// out = shell.Run(cmd)
}
func checkrepos() {
for i, r := range allrepos {
+ log.Warn("scannning", i, r.path)
r.scan()
- log.Info("scanned them all", i)
}
}
@@ -60,16 +87,18 @@ func addRepo(grid *gui.Node, path string) *repo {
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
- newRepo.vLabel = grid.NewLabel("VER")
- newRepo.bLabel = grid.NewLabel("jcarr")
- newRepo.sLabel = grid.NewLabel("dirty")
+ newRepo.bLabel = grid.NewLabel("")
+ newRepo.lastLabel = grid.NewLabel("")
+ newRepo.vLabel = grid.NewLabel("")
+ newRepo.sLabel = grid.NewLabel("")
newRepo.cButton = grid.NewButton("commit", func () {
log.Println("commit")
})
- newRepo.cButton = grid.NewButton("push", func () {
+ newRepo.pButton = grid.NewButton("push", func () {
log.Println("push")
})
+ if path == "" { return newRepo }
allrepos = append(allrepos, newRepo)
return newRepo
}
@@ -80,23 +109,28 @@ func helloworld() {
box := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("test")
- grid := group.NewGrid("test", 6, 1)
+ grid := group.NewGrid("test", 7, 1)
- grid.NewLabel("Repo")
+ grid.NewLabel("go repo")
+ grid.NewLabel("branch")
+ grid.NewLabel("last tag")
grid.NewLabel("Version")
- grid.NewLabel("Current branch")
grid.NewLabel("is dirty?")
grid.NewLabel("commit")
grid.NewLabel("push to")
- newr := addRepo(grid, "go.wit.com/log")
- newr.scan()
+ addRepo(grid, "go.wit.com/log")
addRepo(grid, "go.wit.com/arg")
addRepo(grid, "go.wit.com/spew")
addRepo(grid, "go.wit.com/shell")
addRepo(grid, "")
+ addRepo(grid, "go.wit.com/gui/gui")
+ addRepo(grid, "go.wit.com/gui/widget")
+ addRepo(grid, "go.wit.com/gui/toolkits")
+ addRepo(grid, "go.wit.com/gui/debugger")
addRepo(grid, "go.wit.com/gui/gadgets")
- addRepo(grid, "go.wit.com/gui/gadgets")
+ addRepo(grid, "go.wit.com/gui/digitalocean")
+ addRepo(grid, "go.wit.com/gui/cloudflare")
box.NewButton("checkrepos()", func () {
checkrepos()
@@ -128,22 +162,43 @@ func smartDraw(sw *smartwindow.SmartWindow) {
})
}
-func run(path string, thing string, cmdline string) (bool, string) {
+func fullpath(repo string) string {
+ return "/home/jcarr/go/src/" + repo
+}
+
+func run(path string, thing string, cmdline string) string {
parts := strings.Split(cmdline, " ")
// Create the command
cmd := exec.Command(thing, parts...)
// Set the working directory
- cmd.Dir = "/home/jcarr/go/src/" + path
+ cmd.Dir = fullpath(path)
// Execute the command
output, err := cmd.CombinedOutput()
if err != nil {
log.Error(err, "cmd error'd out", parts)
- return false, ""
+ return ""
}
// Print the output
log.Info(string(output))
- return true, string(output)
+ return string(output)
+}
+
+func listFiles(directory string) []string {
+ var files []string
+ fileInfo, err := os.ReadDir(directory)
+ if err != nil {
+ log.Error(err)
+ return nil
+ }
+
+ for _, file := range fileInfo {
+ if !file.IsDir() {
+ files = append(files, file.Name())
+ }
+ }
+
+ return files
}