changes for repolist package

This commit is contained in:
Jeff Carr 2024-02-17 08:39:09 -06:00
parent 45519f2370
commit 0e26f2024a
2 changed files with 19 additions and 19 deletions

View File

@ -20,7 +20,7 @@ type RepoStatus struct {
window *gadgets.BasicWindow window *gadgets.BasicWindow
// a box of all the git tags // a box of all the git tags
Tags *gitTagBox Tags *GitTagBox
dirtyLabel *gadgets.OneLiner dirtyLabel *gadgets.OneLiner
readOnly *gadgets.OneLiner readOnly *gadgets.OneLiner

View File

@ -10,7 +10,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
type repoTag struct { type Tag struct {
// tracks if the tag is displayed // tracks if the tag is displayed
hidden bool hidden bool
@ -31,14 +31,14 @@ type repoTag struct {
} }
// a GUI box of all the tags in a repo // a GUI box of all the tags in a repo
type gitTagBox struct { type GitTagBox struct {
// the box to list all the tags in // the box to list all the tags in
box *gui.Node box *gui.Node
group *gui.Node group *gui.Node
grid *gui.Node grid *gui.Node
// all the tags // all the tags
tags []*repoTag tags []*Tag
} }
func (rs *RepoStatus) makeTagBox(box *gui.Node) { func (rs *RepoStatus) makeTagBox(box *gui.Node) {
@ -46,7 +46,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
log.Log(WARN, "already scanned tags") log.Log(WARN, "already scanned tags")
return return
} }
tagB := new(gitTagBox) tagB := new(GitTagBox)
rs.Tags = tagB rs.Tags = tagB
tagB.group = box.NewGroup(".git tags for " + rs.String()) tagB.group = box.NewGroup(".git tags for " + rs.String())
@ -103,7 +103,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
lines := strings.Split(output, "\n") lines := strings.Split(output, "\n")
// reverse the git order // reverse the git order
slices.Reverse(lines) slices.Reverse(lines)
tagB.tags = make([]*repoTag, 0) tagB.tags = make([]*Tag, 0)
for i, line := range lines { for i, line := range lines {
var parts []string var parts []string
@ -114,7 +114,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
continue continue
} }
// log.Info("found tag:", i, parts) // log.Info("found tag:", i, parts)
rTag := new(repoTag) rTag := new(Tag)
rTag.tag = grid.NewLabel(parts[3]) rTag.tag = grid.NewLabel(parts[3])
rTag.ref = grid.NewEntrybox(parts[0]) rTag.ref = grid.NewEntrybox(parts[0])
@ -145,16 +145,16 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
// slices.Reverse(rtags.tags) // slices.Reverse(rtags.tags)
} }
func (rtags *gitTagBox) ListAll() []*repoTag { func (rtags *GitTagBox) ListAll() []*Tag {
var tags []*repoTag var tags []*Tag
for _, t := range rtags.tags { for _, t := range rtags.tags {
tags = append(tags, t) tags = append(tags, t)
} }
return tags return tags
} }
func (rtags *gitTagBox) List() []*repoTag { func (rtags *GitTagBox) List() []*Tag {
var tags []*repoTag var tags []*Tag
for _, t := range rtags.tags { for _, t := range rtags.tags {
if t.hidden { if t.hidden {
// log.Info("tag is hidden", i, t.tag.String()) // log.Info("tag is hidden", i, t.tag.String())
@ -166,8 +166,8 @@ func (rtags *gitTagBox) List() []*repoTag {
return tags return tags
} }
func (rtags *gitTagBox) Prune() { func (rtags *GitTagBox) Prune() {
dups := make(map[string]*repoTag) dups := make(map[string]*Tag)
for i, t := range rtags.tags { for i, t := range rtags.tags {
if t == nil { if t == nil {
log.Info("tag empty:", i) log.Info("tag empty:", i)
@ -187,11 +187,11 @@ func (rtags *gitTagBox) Prune() {
} }
// hide tags worth keeping // hide tags worth keeping
func (rtags *gitTagBox) PruneSmart() { func (rtags *GitTagBox) PruneSmart() {
// always keep the first tag // always keep the first tag
var first bool = true var first bool = true
dups := make(map[string]*repoTag) dups := make(map[string]*Tag)
for i, t := range rtags.tags { for i, t := range rtags.tags {
if t == nil { if t == nil {
log.Info("tag empty:", i) log.Info("tag empty:", i)
@ -240,7 +240,7 @@ func (rtags *gitTagBox) PruneSmart() {
// deleting it locally triggers some but when // deleting it locally triggers some but when
// the git server was uncontactable (over IPv6 if that matters, probably it doesn't) // 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 // and then the local delete re-added it into the tag
func (rs *RepoStatus) DeleteTag(rt *repoTag) { func (rs *RepoStatus) DeleteTag(rt *Tag) {
cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()} cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()}
log.Info("RUN:", cmd) log.Info("RUN:", cmd)
err, output := rs.RunCmd(cmd) err, output := rs.RunCmd(cmd)
@ -261,11 +261,11 @@ func (rs *RepoStatus) DeleteTag(rt *repoTag) {
} }
func (rt *repoTag) TagString() string { func (rt *Tag) TagString() string {
return rt.tag.String() return rt.tag.String()
} }
func (rt *repoTag) Hide() { func (rt *Tag) Hide() {
rt.hidden = true rt.hidden = true
rt.tag.Hide() rt.tag.Hide()
rt.ref.Hide() rt.ref.Hide()
@ -274,7 +274,7 @@ func (rt *repoTag) Hide() {
rt.deleteB.Hide() rt.deleteB.Hide()
} }
func (rt *repoTag) Show() { func (rt *Tag) Show() {
rt.hidden = false rt.hidden = false
rt.tag.Show() rt.tag.Show()
rt.ref.Show() rt.ref.Show()