changes for repolist package
This commit is contained in:
parent
45519f2370
commit
0e26f2024a
|
@ -20,7 +20,7 @@ type RepoStatus struct {
|
|||
window *gadgets.BasicWindow
|
||||
|
||||
// a box of all the git tags
|
||||
Tags *gitTagBox
|
||||
Tags *GitTagBox
|
||||
|
||||
dirtyLabel *gadgets.OneLiner
|
||||
readOnly *gadgets.OneLiner
|
||||
|
|
36
tagWindow.go
36
tagWindow.go
|
@ -10,7 +10,7 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
type repoTag struct {
|
||||
type Tag struct {
|
||||
// tracks if the tag is displayed
|
||||
hidden bool
|
||||
|
||||
|
@ -31,14 +31,14 @@ type repoTag struct {
|
|||
}
|
||||
|
||||
// a GUI box of all the tags in a repo
|
||||
type gitTagBox struct {
|
||||
type GitTagBox struct {
|
||||
// the box to list all the tags in
|
||||
box *gui.Node
|
||||
group *gui.Node
|
||||
grid *gui.Node
|
||||
|
||||
// all the tags
|
||||
tags []*repoTag
|
||||
tags []*Tag
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) makeTagBox(box *gui.Node) {
|
||||
|
@ -46,7 +46,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
|
|||
log.Log(WARN, "already scanned tags")
|
||||
return
|
||||
}
|
||||
tagB := new(gitTagBox)
|
||||
tagB := new(GitTagBox)
|
||||
rs.Tags = tagB
|
||||
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")
|
||||
// reverse the git order
|
||||
slices.Reverse(lines)
|
||||
tagB.tags = make([]*repoTag, 0)
|
||||
tagB.tags = make([]*Tag, 0)
|
||||
|
||||
for i, line := range lines {
|
||||
var parts []string
|
||||
|
@ -114,7 +114,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
|
|||
continue
|
||||
}
|
||||
// log.Info("found tag:", i, parts)
|
||||
rTag := new(repoTag)
|
||||
rTag := new(Tag)
|
||||
rTag.tag = grid.NewLabel(parts[3])
|
||||
rTag.ref = grid.NewEntrybox(parts[0])
|
||||
|
||||
|
@ -145,16 +145,16 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) {
|
|||
// slices.Reverse(rtags.tags)
|
||||
}
|
||||
|
||||
func (rtags *gitTagBox) ListAll() []*repoTag {
|
||||
var tags []*repoTag
|
||||
func (rtags *GitTagBox) ListAll() []*Tag {
|
||||
var tags []*Tag
|
||||
for _, t := range rtags.tags {
|
||||
tags = append(tags, t)
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func (rtags *gitTagBox) List() []*repoTag {
|
||||
var tags []*repoTag
|
||||
func (rtags *GitTagBox) List() []*Tag {
|
||||
var tags []*Tag
|
||||
for _, t := range rtags.tags {
|
||||
if t.hidden {
|
||||
// log.Info("tag is hidden", i, t.tag.String())
|
||||
|
@ -166,8 +166,8 @@ func (rtags *gitTagBox) List() []*repoTag {
|
|||
return tags
|
||||
}
|
||||
|
||||
func (rtags *gitTagBox) Prune() {
|
||||
dups := make(map[string]*repoTag)
|
||||
func (rtags *GitTagBox) Prune() {
|
||||
dups := make(map[string]*Tag)
|
||||
for i, t := range rtags.tags {
|
||||
if t == nil {
|
||||
log.Info("tag empty:", i)
|
||||
|
@ -187,11 +187,11 @@ func (rtags *gitTagBox) Prune() {
|
|||
}
|
||||
|
||||
// hide tags worth keeping
|
||||
func (rtags *gitTagBox) PruneSmart() {
|
||||
func (rtags *GitTagBox) PruneSmart() {
|
||||
// always keep the first tag
|
||||
var first bool = true
|
||||
|
||||
dups := make(map[string]*repoTag)
|
||||
dups := make(map[string]*Tag)
|
||||
for i, t := range rtags.tags {
|
||||
if t == nil {
|
||||
log.Info("tag empty:", i)
|
||||
|
@ -240,7 +240,7 @@ func (rtags *gitTagBox) 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 (rs *RepoStatus) DeleteTag(rt *repoTag) {
|
||||
func (rs *RepoStatus) DeleteTag(rt *Tag) {
|
||||
cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()}
|
||||
log.Info("RUN:", 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()
|
||||
}
|
||||
|
||||
func (rt *repoTag) Hide() {
|
||||
func (rt *Tag) Hide() {
|
||||
rt.hidden = true
|
||||
rt.tag.Hide()
|
||||
rt.ref.Hide()
|
||||
|
@ -274,7 +274,7 @@ func (rt *repoTag) Hide() {
|
|||
rt.deleteB.Hide()
|
||||
}
|
||||
|
||||
func (rt *repoTag) Show() {
|
||||
func (rt *Tag) Show() {
|
||||
rt.hidden = false
|
||||
rt.tag.Show()
|
||||
rt.ref.Show()
|
||||
|
|
Loading…
Reference in New Issue