good deal

This commit is contained in:
Jeff Carr 2025-02-22 03:40:37 -06:00
parent df0f0a21c3
commit 844bf0e294
3 changed files with 82 additions and 5 deletions

View File

@ -196,7 +196,8 @@ func drawWindow(win *gadgets.BasicWindow) {
doCheckDirtyAndConfigSave() doCheckDirtyAndConfigSave()
found := findDirty() found := findDirty()
_, box := makeStandardReposWindow("dirty repos", found) _, box := makeStandardReposWindow("dirty repos", found)
box.NewButton("commit all", func() { hbox := box.Box().Horizontal()
hbox.NewButton("commit all", func() {
all := found.SortByFullPath() all := found.SortByFullPath()
for all.Scan() { for all.Scan() {
repo := all.Next() repo := all.Next()

View File

@ -12,6 +12,7 @@ import (
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui" "go.wit.com/gui"
@ -78,6 +79,10 @@ func (r *patchesWindow) submitPatchesBox() {
// make the header table for repo stats // make the header table for repo stats
r.totalOL = gadgets.NewOneLiner(grid, "Total") r.totalOL = gadgets.NewOneLiner(grid, "Total")
grid.NewButton("reset user branches", func() {
resetUserBranchesWindow()
})
grid.NextRow() grid.NextRow()
r.dirtyOL = gadgets.NewOneLiner(grid, "dirty") r.dirtyOL = gadgets.NewOneLiner(grid, "dirty")
grid.NextRow() grid.NextRow()
@ -227,3 +232,60 @@ func (r *patchesWindow) Update() {
r.readonlyOL.SetText(strconv.Itoa(readonly) + " repos") r.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
r.rw.SetText(fmt.Sprintf("%d repos", rw)) r.rw.SetText(fmt.Sprintf("%d repos", rw))
} }
func resetUserBranchesWindow() {
found := gitpb.NewRepos()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
uname := repo.GetUserBranchName()
dname := repo.GetDevelBranchName()
if repo.GetCurrentBranchName() == uname {
log.Info("Repo is on the user branch. Can't delete it.", repo.GetGoPath())
continue
}
b1 := repo.CountDiffObjects(uname, dname)
b2 := repo.CountDiffObjects(dname, uname)
log.Info("user vs devel count", b1, b2)
if b1 == 0 && b2 == 0 {
cmd := []string{"git", "branch", "-D", uname}
log.Info(repo.GetGoPath(), cmd)
repo.RunVerbose(cmd)
repo.Reload()
continue
}
found.Append(repo)
}
win := gadgets.RawBasicWindow("reset user branches")
win.Make()
win.Show()
win.Custom = func() {
// sets the hidden flag to false so Toggle() works
win.Hide()
}
box := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("test buttons")
hbox := group.Box().Horizontal()
hbox.NewButton("force delete user branch", func() {
win.Disable()
defer win.Enable()
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
brname := repo.GetUserBranchName()
cmd := []string{"git", "branch", "-D", brname}
log.Info(repo.GetGoPath(), cmd)
// repo.RunVerbose(cmd)
// repo.Reload()
}
me.forge.SetConfigSave(true)
me.forge.ConfigSave()
})
t := makeStandardReposGrid(found)
t.SetParent(box)
t.ShowTable()
}

View File

@ -5,6 +5,7 @@ package main
import ( import (
"fmt" "fmt"
"os"
"sync" "sync"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
@ -96,8 +97,18 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
found := develBehindMasterProblem() found := develBehindMasterProblem()
group := box.NewGroup("test buttons") group := box.NewGroup("test buttons")
group.NewButton("hello", func() { hbox := group.Box().Horizontal()
log.Info("world") hbox.NewButton("git merge master devel", func() {
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
mname := repo.GetMasterBranchName()
dname := repo.GetDevelBranchName()
cmd := []string{"git", "merge", mname, dname}
log.Info(repo.GetGoPath(), cmd)
}
})
hbox.NewButton("test", func() {
}) })
t := makeStandardReposGrid(found) t := makeStandardReposGrid(found)
@ -119,7 +130,8 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
found := remoteUserBranchProblem() found := remoteUserBranchProblem()
group := box.NewGroup("test buttons") group := box.NewGroup("test buttons")
group.NewButton("git branch delete", func() { hbox := group.Box().Horizontal()
hbox.NewButton("git branch delete", func() {
win.Disable() win.Disable()
defer win.Enable() defer win.Enable()
all := found.SortByFullPath() all := found.SortByFullPath()
@ -127,9 +139,11 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
repo := all.Next() repo := all.Next()
brname := repo.GetUserBranchName() brname := repo.GetUserBranchName()
// git push origin --delete jcarr // git push origin --delete jcarr
os.Setenv("GIT_TERMINAL_PROMPT", "0")
cmd := []string{"git", "push", "origin", "--delete", brname} cmd := []string{"git", "push", "origin", "--delete", brname}
log.Info(repo.GetGoPath(), cmd) log.Info("You may want to run:", repo.GetGoPath(), cmd)
repo.RunVerbose(cmd) repo.RunVerbose(cmd)
os.Unsetenv("GIT_TERMINAL_PROMPT")
// git branch --delete --remote origin/jcarr // git branch --delete --remote origin/jcarr
cmd = []string{"git", "branch", "--delete", "--remote", "origin/" + brname} cmd = []string{"git", "branch", "--delete", "--remote", "origin/" + brname}