diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 110 |
1 files changed, 18 insertions, 92 deletions
@@ -2,10 +2,6 @@ package main import ( - "os" - "strings" - "os/exec" - "go.wit.com/log" "go.wit.com/gui/gui" @@ -38,54 +34,9 @@ func main() { myGui = gui.New().Default() helloworld() - - // This is just a optional goroutine to watch that things are alive gui.Watchdog() } -func (r *repo) scan() { - log.Info("r.path", r.path) - 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")) - for _, tag := range r.tags { - r.tagsDrop.AddText(tag) - } - - // 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() - } -} - func addRepo(grid *gui.Node, path string) *repo { newRepo := new(repo) @@ -113,6 +64,7 @@ func helloworld() { win := gadgets.NewBasicWindow(myGui, "helloworld golang wit/gui window") box := win.Box().NewBox("bw vbox", false) + box2 := win.Box().NewBox("bw vbox", false) group := box.NewGroup("test") grid := group.NewGrid("test", 8, 1) @@ -138,10 +90,25 @@ func helloworld() { addRepo(grid, "go.wit.com/gui/digitalocean") addRepo(grid, "go.wit.com/gui/cloudflare") - box.NewButton("checkrepos()", func () { + box2.NewButton("checkrepos()", func () { checkrepos() }) - box.NewButton("hello", func () { + box2.NewButton("checkout jcarr (all repos)", func () { + for _, r := range allrepos { + r.checkoutBranch("jcarr") + } + }) + box2.NewButton("checkout devel (all repos)", func () { + for _, r := range allrepos { + r.checkoutBranch("devel") + } + }) + box2.NewButton("checkout master (all repos)", func () { + for _, r := range allrepos { + r.checkoutBranch("master") + } + }) + box2.NewButton("hello", func () { log.Println("world") hellosmart() }) @@ -167,44 +134,3 @@ func smartDraw(sw *smartwindow.SmartWindow) { log.Println("smart") }) } - -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 = fullpath(path) - - // Execute the command - output, err := cmd.CombinedOutput() - if err != nil { - log.Error(err, "cmd error'd out", parts) - return "" - } - - // Print the output - log.Info(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 -} |
