correctly cleans remote user branches finally!

This commit is contained in:
Jeff Carr 2025-02-21 16:35:21 -06:00
parent ce938cc73b
commit f8dd6bca59
2 changed files with 30 additions and 67 deletions

View File

@ -204,13 +204,13 @@ func drawWindow(win *gadgets.BasicWindow) {
me.found.AppendByGoPath(repo)
}
makeStandardReposWindow(me.found)
makeStandardReposWindow("All repos", me.found)
})
me.repoDirtyB = grid.NewButton("dirty", func() {
me.found = new(gitpb.Repos)
findDirty()
makeStandardReposWindow(me.found)
makeStandardReposWindow("dirty repos", me.found)
})
me.repoWritableB = grid.NewButton("writable", func() {
@ -225,12 +225,12 @@ func drawWindow(win *gadgets.BasicWindow) {
me.found.AppendByGoPath(repo)
}
makeStandardReposWindow(me.found)
makeStandardReposWindow("Repos that you have write access to", me.found)
})
me.repoDevelMergeB = grid.NewButton("needs merge to devel", func() {
findMergeToDevel()
makeStandardReposWindow(me.found)
makeStandardReposWindow("repos to merge from user to devel", me.found)
})
var problemsWin *repoProblemsWindow
grid.NewButton("Repo Problems", func() {
@ -334,40 +334,6 @@ func drawWindow(win *gadgets.BasicWindow) {
patchWin.initWindow()
patchWin.Show()
})
/*
grid.NewButton("Repo Window", func() {
win.Disable()
defer win.Enable()
if reposWin != nil {
if reposWin.Hidden() {
reposWin.Show()
} else {
reposWin.Hide()
}
return
}
reposWin := new(repoWindow)
reposWin.win = gadgets.RawBasicWindow("All git repositories in ~/go/src/")
reposWin.win.Make()
reposWin.box = reposWin.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
reposWin.win.Custom = func() {
log.Warn("Repo Window close. hidden=true")
// sets the hidden flag to false so Toggle() works
reposWin.win.Hide()
}
reposWin.topbox = reposWin.repoMenu()
reposWin.View = repolist.InitBox(me.forge, reposWin.box)
reposWin.View.Enable()
// need to update this logic
reposWin.View.ScanRepositoriesOld()
reposWin.win.Show()
})
*/
}
// this is the magic that generates a window directly from the protocol buffer
@ -394,34 +360,20 @@ func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable {
}
// this is the magic that generates a window directly from the protocol buffer
func makeStandardReposWindow(pb *gitpb.Repos) {
t := pb.NewTable("testDirty")
sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string {
return r.GetGoPath()
})
// t.Custom = func() {
// log.Info("close grid?")
// }
sf.Custom = func(r *gitpb.Repo) {
log.Info("do button click on", r.GetGoPath())
func makeStandardReposWindow(title string, pb *gitpb.Repos) *gitpb.ReposTable {
win := gadgets.RawBasicWindow(title)
win.Make()
win.Show()
win.Custom = func() {
// sets the hidden flag to false so Toggle() works
win.Hide()
}
t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time {
return repo.NewestTime()
})
t.AddMasterVersion()
t.AddDevelVersion()
t.AddUserVersion()
t.AddCurrentBranchName()
t.AddState()
box := win.Box().NewBox("bw vbox", false)
t := makeStandardReposGrid(pb)
t.SetParent(box)
t.ShowTable()
/*
t.AddStringFunc("zood", func(m *zoopb.Machine) string {
return findVersion(m, "zood")
})
t.AddTimeFunc("age", func(m *zoopb.Machine) time.Time {
return m.Laststamp.AsTime()
})
*/
return t
}
func findMergeToDevel() {

View File

@ -123,10 +123,21 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
found := remoteUserBranchProblem()
group := box.NewGroup("test buttons")
group.NewButton("git branch delete", func() {
win.Disable()
defer win.Enable()
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
log.Info("git branch -D jcarr", repo.GetGoPath())
brname := repo.GetUserBranchName()
// git push origin --delete jcarr
cmd := []string{"git", "push", "origin", "--delete", brname}
log.Info(repo.GetGoPath(), cmd)
repo.RunVerbose(cmd)
// git branch --delete --remote origin/jcarr
cmd = []string{"git", "branch", "--delete", "--remote", "origin/" + brname}
log.Info(repo.GetGoPath(), cmd)
repo.RunVerbose(cmd)
}
})
@ -144,14 +155,14 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
txt = fmt.Sprintf("remote devel != local devel (%d)", found.Len())
grid.NewButton(txt, func() {
found := develRemoteProblem()
makeStandardReposWindow(found)
makeStandardReposWindow(txt, found)
})
found = masterRemoteProblem()
txt = fmt.Sprintf("remote master != local master (%d)", found.Len())
grid.NewButton(txt, func() {
found := masterRemoteProblem()
makeStandardReposWindow(found)
makeStandardReposWindow(txt, found)
})
grid.NextRow()