diff options
| author | Jeff Carr <[email protected]> | 2024-02-15 22:50:50 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-15 22:50:50 -0600 |
| commit | 2bc2096e841f3b262563126feb8a7a4c2b66f090 (patch) | |
| tree | a940a0200555f1a75096cdc1895246ed46ffb159 /tagWindow.go | |
| parent | e6eb92845ace066aa36c8730d28c3e53fe6bdca8 (diff) | |
xterm fixes
also a i18n syntax idea
show all tags in the main window
Diffstat (limited to 'tagWindow.go')
| -rw-r--r-- | tagWindow.go | 95 |
1 files changed, 33 insertions, 62 deletions
diff --git a/tagWindow.go b/tagWindow.go index c92e961..c476f8d 100644 --- a/tagWindow.go +++ b/tagWindow.go @@ -6,7 +6,6 @@ import ( "strings" "go.wit.com/gui" - "go.wit.com/lib/gadgets" "go.wit.com/log" ) @@ -30,13 +29,8 @@ type repoTag struct { deleteB *gui.Node } -type repoTags struct { - // the originating repository - rs *RepoStatus - - // the window for the tags - window *gadgets.BasicWindow - +// a GUI box of all the tags in a repo +type gitTagBox struct { // the box to list all the tags in box *gui.Node group *gui.Node @@ -46,64 +40,43 @@ type repoTags struct { tags []*repoTag } -func (tw *repoTags) Hidden() bool { - return tw.window.Hidden() -} - -func (tw *repoTags) Show() { - log.Info("tw *repoTags Show()") - tw.window.Show() -} - -func (tw *repoTags) Hide() { - log.Info("tw *repoTags Hide()") - tw.window.Hide() -} - -func (rs *RepoStatus) TagWindow() *repoTags { - // return the window if it was already created - tags := new(repoTags) - rs.TagsW = tags - tags.rs = rs - - tags.window = gadgets.RawBasicWindow("tags " + rs.String()).Make() - vbox := tags.window.Box() - - tags.newTagBox(vbox) - return tags -} - -func (tagW *repoTags) newTagBox(box *gui.Node) { - tagW.group = box.NewGroup(".git tags for " + tagW.rs.String()) +func (rs *RepoStatus) makeTagBox(box *gui.Node) { + if rs.Tags != nil { + log.Log(WARN, "already scanned tags") + return + } + tagB := new(gitTagBox) + rs.Tags = tagB + tagB.group = box.NewGroup(".git tags for " + rs.String()) - // tagW.group.NewButton("prune tags", func() { - // tagW.Prune() + // tagB.group.NewButton("prune tags", func() { + // tagB.Prune() // }) var dups *gui.Node - dups = tagW.group.NewCheckbox("Show duplicate tags").SetChecked(false) + dups = tagB.group.NewCheckbox("Show duplicate tags").SetChecked(false) dups.Custom = func() { if dups.Checked() { - tagW.Prune() + tagB.Prune() } else { - for _, t := range tagW.tags { + for _, t := range tagB.tags { t.Show() } } } - tagW.group.NewButton("delete all", func() { - for i, t := range tagW.tags { + tagB.group.NewButton("delete all", func() { + for i, t := range tagB.tags { if t.hidden { // log.Info("tag is hidden", i, t.tag.String()) continue } log.Info("tag is shown", i, t.tag.String()) - tagW.Delete(t) + rs.DeleteTag(t) } }) - grid := tagW.group.NewGrid("tags", 0, 0) - tagW.grid = grid + grid := tagB.group.NewGrid("tags", 0, 0) + tagB.grid = grid grid.NewLabel("version") grid.NewLabel("ref") @@ -117,11 +90,11 @@ func (tagW *repoTags) newTagBox(box *gui.Node) { // git rev-parse HEAD // if last tag == HEAD, then remove it - tags := []string{"%(tag)", "%(*objectname)", "%(taggerdate:raw)", "%(subject)"} + tags := []string{"%(tag)", "%(*objectname)", "%(taggerdate:raw)", "%(subject)", "%(*authorname)", "%(*authoremail)"} format := strings.Join(tags, "_,,,_") cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format} log.Info("RUNNING:", strings.Join(cmd, " ")) - err, output := tagW.rs.RunCmd(cmd) + err, output := rs.RunCmd(cmd) if err != nil { output = "git error_,,,_a_,,,_b_,,,c" } @@ -129,7 +102,7 @@ func (tagW *repoTags) newTagBox(box *gui.Node) { lines := strings.Split(output, "\n") // reverse the git order slices.Reverse(lines) - tagW.tags = make([]*repoTag, 0) + tagB.tags = make([]*repoTag, 0) for i, line := range lines { var parts []string @@ -143,7 +116,7 @@ func (tagW *repoTags) newTagBox(box *gui.Node) { rTag.tag = grid.NewLabel(parts[0]) rTag.ref = grid.NewEntrybox(parts[1]) - stamp, dur := getDateStamp(parts[2]) // + _, stamp, dur := getDateStamp(parts[2]) // rTag.date = grid.NewLabel(stamp) grid.NewLabel(dur) @@ -155,14 +128,14 @@ func (tagW *repoTags) newTagBox(box *gui.Node) { all = append(all, []string{"git", "tag", "--delete", tagversion}) all = append(all, []string{"git", "push", "--delete", "origin", tagversion}) - if tagW.rs.DoAll(all) { - log.Info("TAG DELETED", tagW.rs.String(), tagversion) + if rs.DoAll(all) { + log.Info("TAG DELETED", rs.String(), tagversion) } else { - log.Info("TAG DELETE FAILED", tagW.rs.String(), tagversion) + log.Info("TAG DELETE FAILED", rs.String(), tagversion) } }) - tagW.tags = append(tagW.tags, rTag) + tagB.tags = append(tagB.tags, rTag) // works like a typerwriter grid.NextRow() } @@ -170,7 +143,7 @@ func (tagW *repoTags) newTagBox(box *gui.Node) { // slices.Reverse(rtags.tags) } -func (rtags *repoTags) ListAll() []*repoTag { +func (rtags *gitTagBox) ListAll() []*repoTag { var tags []*repoTag for _, t := range rtags.tags { tags = append(tags, t) @@ -178,7 +151,7 @@ func (rtags *repoTags) ListAll() []*repoTag { return tags } -func (rtags *repoTags) List() []*repoTag { +func (rtags *gitTagBox) List() []*repoTag { var tags []*repoTag for _, t := range rtags.tags { if t.hidden { @@ -191,7 +164,7 @@ func (rtags *repoTags) List() []*repoTag { return tags } -func (rtags *repoTags) Prune() { +func (rtags *gitTagBox) Prune() { dups := make(map[string]*repoTag) for i, t := range rtags.tags { if t == nil { @@ -212,7 +185,7 @@ func (rtags *repoTags) Prune() { } // hide tags worth keeping -func (rtags *repoTags) PruneSmart() { +func (rtags *gitTagBox) PruneSmart() { // always keep the first tag var first bool = true @@ -265,9 +238,7 @@ func (rtags *repoTags) PruneSmart() { // deleting it locally triggers some but when // the git server was uncontactable (over IPv6 if that matters, probably it doesn't) // and then the local delete re-added it into the tag -func (rtags *repoTags) Delete(rt *repoTag) { - rs := rtags.rs - +func (rs *RepoStatus) DeleteTag(rt *repoTag) { cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()} log.Info("RUN:", cmd) err, output := rs.RunCmd(cmd) |
