remove perfect branches works

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-15 08:11:08 -06:00
parent 74502ed5fb
commit e240e4149f
7 changed files with 185 additions and 47 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
!Makefile
!*.go
!go.*
!myrepolist

View File

@ -1,7 +1,11 @@
all:
echo "build it!"
go build -v -x
./myrepos
-mkdir -p plugins/
-cp myrepolist plugins/
-cp ~/go/src/go.wit.com/gui/toolkits/*.so plugins/
go install -v -x
# go build -v -x
myrepos
# ./myrepos >/tmp/myrepos.stderr 2>&1
redomod:

118
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"os/user"
"embed"
"go.wit.com/log"
@ -11,11 +12,15 @@ import (
"go.wit.com/gui/gadgets/repostatus"
)
//go:embed plugins/*
var resToolkit embed.FS
func main() {
myGui = gui.New().Default()
myGui = gui.New()
myGui.InitEmbed(resToolkit)
myGui.Default()
repoworld()
gui.Watchdog()
}
@ -30,19 +35,19 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
}
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
newRepo.bLabel = grid.NewLabel("")
newRepo.lastLabel = grid.NewLabel("")
newRepo.vLabel = grid.NewLabel("")
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
newRepo.lastTag = grid.NewLabel("").SetProgName("lastTag")
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
newRepo.masterName = grid.NewLabel("")
newRepo.masterVersion = grid.NewLabel("")
newRepo.develName = grid.NewLabel("")
newRepo.develVersion = grid.NewLabel("")
newRepo.userName = grid.NewLabel("")
newRepo.userVersion = grid.NewLabel("")
newRepo.masterName = grid.NewLabel("").SetProgName("masterName")
newRepo.masterVersion = grid.NewLabel("").SetProgName("masterVersion")
newRepo.develName = grid.NewLabel("").SetProgName("develName")
newRepo.develVersion = grid.NewLabel("").SetProgName("develVersion")
newRepo.userName = grid.NewLabel("").SetProgName("userName")
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
newRepo.dirtyLabel = grid.NewLabel("")
/*
newRepo.pButton = grid.NewButton("rescan", func () {
newRepo.newScan()
})
@ -63,6 +68,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
log.Warn("status window exists. trying Hide() here")
newRepo.status.Hide()
})
*/
grid.NewButton("Show()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
@ -92,13 +98,11 @@ func repoworld() {
reposbox = reposwin.Box().NewBox("bw vbox", false)
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
reposgrid = reposgroup.NewGrid("test", 15, 1)
reposgrid = reposgroup.NewGrid("test", 11, 1)
reposgrid.NewLabel("")
reposgrid.NewLabel("branch")
reposgrid.NewLabel("last tag")
reposgrid.NewLabel("Current Version")
// reposgrid.NewLabel("tags")
reposgrid.NewLabel("last tag").SetProgName("last tag")
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
reposgrid.NewLabel("master")
reposgrid.NewLabel("version")
reposgrid.NewLabel("devel")
@ -106,9 +110,6 @@ func repoworld() {
reposgrid.NewLabel("user")
reposgrid.NewLabel("version")
reposgrid.NewLabel("Status")
reposgrid.NewLabel("rescan")
reposgrid.NewLabel("Update()")
reposgrid.NewLabel("Hide()")
reposgrid.NewLabel("Show()")
repos := myrepolist()
@ -123,24 +124,87 @@ func repoworld() {
}
box2 := reposwin.Box().NewBox("bw vbox", false)
box2.NewButton("reposgrid.Margin()", func () {
log.Warn("reposgrid.Margin() RUN NOW")
reposgrid.Margin()
log.Warn("reposgrid.Pad() RUN NOW")
reposgrid.Pad()
buildOptions := box2.NewGrid("buildOptions",2, 1)
title := gadgets.NewOneLiner(buildOptions, "Branch and build")
title.Set("options")
guiBranch := gadgets.NewBasicCombobox(buildOptions, "Select GUI branch")
guiBranch.Add("guimaster")
guiBranch.Add("guidevel")
guiBranch.Add("jcarr")
buildOptions.NewLabel("only PERFECT")
buildOptions.NewButton("Find", func () {
log.Warn("delete every repo marked PERFECT")
var newCmds [][]string
for _, repo := range allrepos {
status := repo.getStatus()
if status == "PERFECT" {
var line []string
line = append(line, "rm", "-rf", "go/src/" + repo.path)
newCmds = append(newCmds, line)
}
}
script = newCmds
doit.Enable()
setGitCommands()
})
box2.NewButton("status.Update() all", func () {
buildOptions.NewLabel("start over")
buildOptions.NewButton("rm src & pkgs", func () {
var newCmds [][]string
var dirty bool = false
for _, repo := range allrepos {
status := repo.getStatus()
if status == "dirty" {
dirty = true
break
}
}
line := []string{"rm", "-rf", "go/src/"}
newCmds = append(newCmds, line)
newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"})
if dirty {
line := []string{"can't do this with dirty repos"}
newCmds = append(newCmds, line)
doit.Disable()
} else {
doit.Enable()
}
script = newCmds
setGitCommands()
})
buildOptions.NewLabel("repo pkg's")
buildOptions.NewButton("rm ~/go/pkg/", func () {
log.Warn("delete every repo here but skip dirty ones")
cmds.Set("rm -rf ~/go/pkg/")
})
buildOptions.NewButton("status.Update() all", func () {
for _, repo := range allrepos {
repo.status.Update()
}
})
box2.NewButton("rescan all", func () {
buildOptions.NewButton("rescan all", func () {
for _, repo := range allrepos {
repo.newScan()
}
})
buildOptions.NewLabel("cmd")
cmds = buildOptions.NewLabel("ls")
buildOptions.NewLabel("Doit")
doit = buildOptions.NewButton("run commands", func () {
doit.Disable()
log.Warn("should run the commands here")
if runCommands() {
log.Warn("EVERYTHING WORKED")
} else {
log.Warn("EVERYTHING DID NOT WORK")
}
})
reposwin.Draw()
}

15
myrepolist Normal file
View File

@ -0,0 +1,15 @@
go.wit.com/log
go.wit.com/gui/widget
go.wit.com/gui/gui
go.wit.com/gui/toolkits
go.wit.com/gui/debugger
go.wit.com/gui/gadgets
go.wit.com/gui/gadgets/repostatus
go.wit.com/gui/digitalocean
go.wit.com/gui/cloudflare
go.wit.com/apps/control-panel-dns main
go.wit.com/apps/control-panel-vpn
go.wit.com/apps/autotypist

41
scan.go
View File

@ -36,26 +36,37 @@ func (r *repo) newScan() bool {
cbname := r.status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion()
ltversion := r.status.GetLastTagVersion()
r.lastLabel.Set(cbname + "\n" + cbversion)
r.vLabel.Set(cbname + "\n" + ltversion)
lasttag := r.status.GetLastTagVersion()
r.lastTag.Set(lasttag)
r.vLabel.Set(cbname + " " + cbversion)
if r.status.CheckDirty() {
log.Warn("CheckDirty() true")
r.dirtyLabel.Set("dirty")
status := r.getStatus()
if status == "dirty" {
r.dirtyLabel.Set(status)
return false
}
log.Warn("CheckDirty() no")
r.dirtyLabel.Set("not dirty")
if status == "merge" {
r.dirtyLabel.Set(status)
return false
}
if status == "PERFECT" {
r.dirtyLabel.Set(status)
return true
}
r.dirtyLabel.Set("unknown " + status)
return false
}
func (r *repo) getStatus() string {
if r.status.CheckDirty() {
log.Warn("CheckDirty() true")
return "dirty"
}
if r.status.CheckBranches() {
log.Warn("Branches are Perfect")
r.dirtyLabel.SetText("PERFECT")
return true
} else {
log.Warn("Branches are not Perfect")
r.dirtyLabel.SetText("merge")
return "PERFECT"
}
return false
log.Warn("Branches are not Perfect")
return "merge"
}

View File

@ -13,6 +13,9 @@ var reposwin *gadgets.BasicWindow
var reposbox *gui.Node
var reposgrid *gui.Node
var reposgroup *gui.Node
var cmds *gui.Node
var script [][]string
var doit *gui.Node
var allrepos []*repo
@ -20,11 +23,11 @@ type repo struct {
path string
lasttagrev string
lasttag string
tags []string
// tags []string
pLabel *gui.Node // path label
bLabel *gui.Node // branch label
lastLabel *gui.Node // last tagged version label
// bLabel *gui.Node // branch label
lastTag *gui.Node // last tagged version label
vLabel *gui.Node // version label
// tagsDrop *gui.Node // list of all tags
dirtyLabel *gui.Node // git state (dirty or not?)

40
unix.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"strings"
"go.wit.com/log"
"go.wit.com/gui/gadgets/repostatus"
)
var repopath string = "/home/jcarr/"
func runCommands() bool {
for _, line := range script {
s := strings.Join(line, " ")
log.Warn("NEED TO RUN:", s)
err, b, output := repostatus.RunCmd(repopath, line)
if err != nil {
log.Warn("ABEND EXECUTION")
log.Warn("error =", err)
log.Warn("output =", output)
return false
}
log.Warn("Returned with b =", b)
log.Warn("output was =", output)
log.Warn("RUN DONE")
}
return true
}
func setGitCommands() {
var tmp []string
// convert to displayable to the user text
for _, line := range script {
s := strings.Join(line, " ")
log.Warn("s =", s)
tmp = append(tmp, s)
}
cmds.Set(strings.Join(tmp, "\n"))
}