2024-02-07 13:04:25 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/lib/gui/repostatus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var tagW *tagWindow
|
|
|
|
|
|
|
|
type tagWindow struct {
|
|
|
|
win *gadgets.BasicWindow
|
|
|
|
box *gui.Node
|
|
|
|
grid *gui.Node
|
|
|
|
group *gui.Node
|
|
|
|
allTags []*gitTag
|
|
|
|
}
|
|
|
|
|
|
|
|
type gitTag struct {
|
|
|
|
rs *repostatus.RepoStatus
|
|
|
|
hidden bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeTagWindow() *tagWindow {
|
|
|
|
if tagW != nil {
|
|
|
|
tagW.win.Toggle()
|
|
|
|
return tagW
|
|
|
|
}
|
|
|
|
tagW = new(tagWindow)
|
|
|
|
tagW.win = gadgets.NewBasicWindow(me.myGui, "git tag tasks")
|
|
|
|
tagW.win.Custom = func() {
|
|
|
|
log.Warn("got to close")
|
|
|
|
}
|
|
|
|
|
|
|
|
tagW.win.Make()
|
|
|
|
tagW.win.StandardClose()
|
|
|
|
tagW.win.Draw()
|
|
|
|
|
|
|
|
tagW.box = tagW.win.Box()
|
|
|
|
tagW.group = tagW.box.NewGroup("tags")
|
2024-02-09 04:53:26 -06:00
|
|
|
tagW.grid = tagW.box.RawGrid()
|
2024-02-07 13:04:25 -06:00
|
|
|
|
|
|
|
tagW.group.NewButton("list all tags", func() {
|
|
|
|
me.autotypistWindow.Disable()
|
|
|
|
defer me.autotypistWindow.Enable()
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
tagsW := repo.status.TagsW
|
|
|
|
if tagsW == nil {
|
|
|
|
repo.status.TagWindow()
|
|
|
|
tagsW = repo.status.TagsW
|
|
|
|
// tagsW.Prune()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
allTags := tagsW.ListAll()
|
|
|
|
for _, t := range allTags {
|
|
|
|
log.Info("found tag:", t.TagString(), "from", repo.status.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
tagW.group.NewButton("delete all dup tags", func() {
|
|
|
|
me.autotypistWindow.Disable()
|
|
|
|
defer me.autotypistWindow.Enable()
|
|
|
|
for _, repo := range me.allrepos {
|
2024-02-09 04:53:26 -06:00
|
|
|
if repo.String() == "go.wit.com/log" {
|
|
|
|
// only do log for now
|
|
|
|
} else {
|
|
|
|
// continue
|
|
|
|
}
|
2024-02-07 13:04:25 -06:00
|
|
|
tagsW := repo.status.TagsW
|
|
|
|
if tagsW == nil {
|
|
|
|
repo.status.TagWindow()
|
|
|
|
tagsW = repo.status.TagsW
|
|
|
|
continue
|
|
|
|
}
|
2024-02-09 04:08:21 -06:00
|
|
|
tagsW.PruneSmart()
|
2024-02-07 13:04:25 -06:00
|
|
|
deleteTags := tagsW.List()
|
|
|
|
for _, t := range deleteTags {
|
2024-02-09 04:53:26 -06:00
|
|
|
tagW.grid.NewLabel(t.TagString())
|
|
|
|
tagW.grid.NewLabel(repo.status.String())
|
|
|
|
tagW.grid.NewButton("delete", func() {
|
|
|
|
tagsW.Delete(t)
|
|
|
|
})
|
|
|
|
tagW.grid.NextRow()
|
2024-02-07 13:04:25 -06:00
|
|
|
if me.autoDryRun.Checked() {
|
|
|
|
log.Info("delete tag --dry-run:", t.TagString(), "from", repo.status.String())
|
|
|
|
} else {
|
|
|
|
log.Info("Deleting tag:", t.TagString(), "from", repo.status.String())
|
2024-02-09 04:08:21 -06:00
|
|
|
tagsW.Delete(t)
|
2024-02-07 13:04:25 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-09 04:08:21 -06:00
|
|
|
if ! me.autoDryRun.Checked() {
|
|
|
|
return
|
|
|
|
}
|
2024-02-07 13:04:25 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
return tagW
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *gitTag) Hide() {
|
|
|
|
t.hidden = true
|
|
|
|
}
|