xterm fixes
also a i18n syntax idea show all tags in the main window
This commit is contained in:
parent
e6eb92845a
commit
2bc2096e84
4
Makefile
4
Makefile
|
@ -1,7 +1,5 @@
|
||||||
all:
|
all:
|
||||||
@echo
|
GO111MODULE=off go build
|
||||||
@echo Run: make redomod
|
|
||||||
@echo
|
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rs *RepoStatus) makeBranchesBox() {
|
func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
|
||||||
rs.gitBranchesGroup = rs.window.Box().NewGroup("branches")
|
rs.gitBranchesGroup = parent.NewGroup("branches") // `progname:"BRANCHES"` // can the toolkits use these for i18n support?
|
||||||
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0)
|
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0)
|
||||||
|
|
||||||
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
|
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") // `progname:"LASTTAG"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
|
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master") // `progname:"MASTERBRANCH"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
|
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel") // `progname:"DEVELBRANCH"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
|
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user") // `progname:"USERBRANCH"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch")
|
rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch") // `progname:"CURRENTBRANCH"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version")
|
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version") // `progname:"CURRENTVERSION"`
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
rs.switchBranchB = newgrid.NewButton("Switch Branch", func() {
|
rs.switchBranchB = newgrid.NewButton("Switch Branch", func() { // `progname:"SWITCH"`
|
||||||
bname := rs.targetBranch.String()
|
bname := rs.targetBranch.String()
|
||||||
log.Info("Should switch to branch", bname, "here")
|
log.Info("Should switch to branch", bname, "here")
|
||||||
|
|
||||||
|
@ -38,12 +41,16 @@ func (rs *RepoStatus) makeBranchesBox() {
|
||||||
rs.UpdateCurrent()
|
rs.UpdateCurrent()
|
||||||
})
|
})
|
||||||
|
|
||||||
rs.targetBranch = newgrid.NewDropdown()
|
rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"`
|
||||||
// rs.targetBranch.AddText("master")
|
// rs.targetBranch.AddText("master")
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
rs.showBranchesButton = newgrid.NewButton("scan branches()", func() {
|
rs.showBranchesButton = newgrid.NewButton("scan branches()", func() {
|
||||||
all := rs.getBranches()
|
err, out := rs.RunCmd([]string{"git", "branch", "--all"})
|
||||||
|
if err != nil {
|
||||||
|
log.Log(WARN, "git branch failed", rs.String())
|
||||||
|
}
|
||||||
|
all := strings.Split(out, "\n")
|
||||||
for i, s := range all {
|
for i, s := range all {
|
||||||
log.Log(WARN, "found branch", i, s)
|
log.Log(WARN, "found branch", i, s)
|
||||||
rs.targetBranch.AddText(s)
|
rs.targetBranch.AddText(s)
|
||||||
|
|
28
common.go
28
common.go
|
@ -17,6 +17,30 @@ func (rs *RepoStatus) Changed() bool {
|
||||||
return rs.changed
|
return rs.changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecate this. returns the gopath right now
|
||||||
|
func (rs *RepoStatus) String() string {
|
||||||
|
log.Warn("RepoStatus.String() is to be deprecated")
|
||||||
|
return rs.path.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the go path for the repo. "go.wit.com/apps/autotypist"
|
||||||
|
func (rs *RepoStatus) GoName() string {
|
||||||
|
return rs.goSrcPath.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the filesystem path to the repo
|
||||||
|
func (rs *RepoStatus) Path() string {
|
||||||
|
return rs.realPath.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (rs *RepoStatus) GetPath() string {
|
||||||
|
return rs.path.String()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
func (rs *RepoStatus) Draw() {
|
func (rs *RepoStatus) Draw() {
|
||||||
if !rs.Ready() {
|
if !rs.Ready() {
|
||||||
return
|
return
|
||||||
|
@ -24,6 +48,7 @@ func (rs *RepoStatus) Draw() {
|
||||||
log.Log(CHANGE, "Draw() window ready =", rs.ready)
|
log.Log(CHANGE, "Draw() window ready =", rs.ready)
|
||||||
rs.window.TestDraw()
|
rs.window.TestDraw()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (rs *RepoStatus) Show() {
|
func (rs *RepoStatus) Show() {
|
||||||
if !rs.Ready() {
|
if !rs.Ready() {
|
||||||
|
@ -100,7 +125,8 @@ func (rs *RepoStatus) Build() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
log.Info("need to build here", rs.String())
|
log.Info("need to build here", rs.String())
|
||||||
rs.RunCmd([]string{"go", "build", "-v", "-x"})
|
// rs.RunCmd([]string{"go", "build", "-v", "-x"})
|
||||||
|
rs.XtermBash([]string{"go", "build", "-v", "-x"})
|
||||||
if rs.Exists(name) {
|
if rs.Exists(name) {
|
||||||
log.Warn("build worked", name)
|
log.Warn("build worked", name)
|
||||||
return true
|
return true
|
||||||
|
|
22
draw.go
22
draw.go
|
@ -4,30 +4,14 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
// creates the actual widgets.
|
func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
|
||||||
// it's assumed you are always passing in a box
|
rs.gitStatusGroup = box.NewGroup("What GIT Knows It Has")
|
||||||
func (rs *RepoStatus) draw() {
|
|
||||||
if !rs.Ready() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// display the status of the git repository
|
|
||||||
rs.drawGitStatus()
|
|
||||||
|
|
||||||
// display the git branches and options
|
|
||||||
rs.makeBranchesBox()
|
|
||||||
|
|
||||||
// show standard git commit and merge controls
|
|
||||||
rs.drawGitCommands()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) drawGitStatus() {
|
|
||||||
rs.gitStatusGroup = rs.window.Box().NewGroup("What GIT Knows It Has")
|
|
||||||
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
||||||
newgrid.Margin()
|
newgrid.Margin()
|
||||||
newgrid.Pad()
|
newgrid.Pad()
|
||||||
|
|
15
git.go
15
git.go
|
@ -2,6 +2,7 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -9,16 +10,6 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rs *RepoStatus) String() string {
|
|
||||||
return rs.path.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
func (rs *RepoStatus) GetPath() string {
|
|
||||||
return rs.path.String()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (rs *RepoStatus) GetCurrentBranchName() string {
|
func (rs *RepoStatus) GetCurrentBranchName() string {
|
||||||
return rs.currentBranch.String()
|
return rs.currentBranch.String()
|
||||||
}
|
}
|
||||||
|
@ -27,6 +18,10 @@ func (rs *RepoStatus) GetCurrentBranchVersion() string {
|
||||||
return rs.currentVersion.String()
|
return rs.currentVersion.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) LastTagAge() (time.Time, string) {
|
||||||
|
return time.Now(), rs.lasttag.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) GetLastTagVersion() string {
|
func (rs *RepoStatus) GetLastTagVersion() string {
|
||||||
return rs.lasttag.String()
|
return rs.lasttag.String()
|
||||||
}
|
}
|
||||||
|
|
18
modifyBox.go
18
modifyBox.go
|
@ -1,12 +1,13 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rs *RepoStatus) drawGitCommands() {
|
func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
|
||||||
rs.gitCommandsGroup = rs.window.Box().NewGroup("modify")
|
rs.gitCommandsGroup = box.NewGroup("modify")
|
||||||
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 0, 0)
|
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 0, 0)
|
||||||
|
|
||||||
newgrid.NewButton("update", func() {
|
newgrid.NewButton("update", func() {
|
||||||
|
@ -25,19 +26,6 @@ func (rs *RepoStatus) drawGitCommands() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
newgrid.NewButton("git tags window", func() {
|
|
||||||
if rs.TagsW == nil {
|
|
||||||
log.Warn("error: found rs.TagsW == nil")
|
|
||||||
rs.TagsW = rs.TagWindow()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rs.TagsW.Hidden() {
|
|
||||||
rs.TagsW.Show()
|
|
||||||
} else {
|
|
||||||
rs.TagsW.Show()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
newgrid.NewButton("show .git/config", func() {
|
newgrid.NewButton("show .git/config", func() {
|
||||||
if rs.gitConfig == nil {
|
if rs.gitConfig == nil {
|
||||||
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
|
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
|
||||||
|
|
43
new.go
43
new.go
|
@ -11,6 +11,10 @@ import (
|
||||||
|
|
||||||
var windowMap map[string]*RepoStatus
|
var windowMap map[string]*RepoStatus
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
windowMap = make(map[string]*RepoStatus)
|
||||||
|
}
|
||||||
|
|
||||||
func ListAll() {
|
func ListAll() {
|
||||||
for path, rs := range windowMap {
|
for path, rs := range windowMap {
|
||||||
log.Warn(rs.GetMasterVersion(), path)
|
log.Warn(rs.GetMasterVersion(), path)
|
||||||
|
@ -35,16 +39,27 @@ func NewRepoStatusWindow(path string) *RepoStatus {
|
||||||
return windowMap[path]
|
return windowMap[path]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var realpath string
|
||||||
|
|
||||||
homeDir, err := os.UserHomeDir()
|
homeDir, err := os.UserHomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log(WARN, "Error getting home directory:", err)
|
log.Log(WARN, "Error getting home directory:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
goSrcDir := filepath.Join(homeDir, "go/src")
|
goSrcDir := filepath.Join(homeDir, "go/src")
|
||||||
realpath := filepath.Join(goSrcDir, path)
|
|
||||||
|
|
||||||
filename := filepath.Join(goSrcDir, path, ".git/config")
|
// allow arbitrary paths, otherwise, assume the repo is in ~/go/src
|
||||||
|
if strings.HasPrefix(path, "/") {
|
||||||
|
realpath = path
|
||||||
|
} else if strings.HasPrefix(path, "~") {
|
||||||
|
// TODO: example this to homedir
|
||||||
|
tmp := strings.TrimPrefix(path, "~")
|
||||||
|
realpath = filepath.Join(homeDir, tmp)
|
||||||
|
} else {
|
||||||
|
realpath = filepath.Join(goSrcDir, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
filename := filepath.Join(realpath, ".git/config")
|
||||||
|
|
||||||
_, err = os.Open(filename)
|
_, err = os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -60,18 +75,34 @@ func NewRepoStatusWindow(path string) *RepoStatus {
|
||||||
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
||||||
rs.window.Horizontal()
|
rs.window.Horizontal()
|
||||||
rs.window.Make()
|
rs.window.Make()
|
||||||
|
basebox := rs.window.Box()
|
||||||
|
group := basebox.NewGroup("stuff")
|
||||||
|
primarybox := group.Box()
|
||||||
|
primarybox.Horizontal()
|
||||||
|
box2 := group.Box()
|
||||||
rs.ready = true
|
rs.ready = true
|
||||||
rs.window.Custom = func() {
|
rs.window.Custom = func() {
|
||||||
rs.Hide()
|
rs.Hide()
|
||||||
log.Warn("repostatus user closed the window()")
|
log.Warn("repostatus user closed the window()")
|
||||||
}
|
}
|
||||||
rs.draw()
|
|
||||||
|
// display the status of the git repository
|
||||||
|
rs.drawGitStatus(primarybox)
|
||||||
|
|
||||||
|
// display the git branches and options
|
||||||
|
rs.makeBranchesBox(primarybox)
|
||||||
|
|
||||||
|
// show standard git commit and merge controls
|
||||||
|
rs.drawGitCommands(primarybox)
|
||||||
|
|
||||||
// save ~/go/src & the whole path strings
|
// save ~/go/src & the whole path strings
|
||||||
rs.path.SetValue(path)
|
rs.path.SetValue(path)
|
||||||
rs.goSrcPath.SetValue(goSrcDir)
|
rs.goSrcPath.SetValue(goSrcDir)
|
||||||
rs.realPath.SetValue(realpath)
|
rs.realPath.SetValue(realpath)
|
||||||
|
|
||||||
|
// add all the tags
|
||||||
|
rs.makeTagBox(box2)
|
||||||
|
|
||||||
rs.readGitConfig()
|
rs.readGitConfig()
|
||||||
|
|
||||||
rs.readOnly.SetValue("true")
|
rs.readOnly.SetValue("true")
|
||||||
|
@ -86,7 +117,3 @@ func NewRepoStatusWindow(path string) *RepoStatus {
|
||||||
windowMap[path] = rs
|
windowMap[path] = rs
|
||||||
return rs
|
return rs
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
windowMap = make(map[string]*RepoStatus)
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ type RepoStatus struct {
|
||||||
|
|
||||||
window *gadgets.BasicWindow
|
window *gadgets.BasicWindow
|
||||||
|
|
||||||
// a window to manage your .git tags
|
// a box of all the git tags
|
||||||
TagsW *repoTags
|
Tags *gitTagBox
|
||||||
|
|
||||||
dirtyLabel *gadgets.OneLiner
|
dirtyLabel *gadgets.OneLiner
|
||||||
readOnly *gadgets.OneLiner
|
readOnly *gadgets.OneLiner
|
||||||
|
|
95
tagWindow.go
95
tagWindow.go
|
@ -6,7 +6,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,13 +29,8 @@ type repoTag struct {
|
||||||
deleteB *gui.Node
|
deleteB *gui.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
type repoTags struct {
|
// a GUI box of all the tags in a repo
|
||||||
// the originating repository
|
type gitTagBox struct {
|
||||||
rs *RepoStatus
|
|
||||||
|
|
||||||
// the window for the tags
|
|
||||||
window *gadgets.BasicWindow
|
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -46,64 +40,43 @@ type repoTags struct {
|
||||||
tags []*repoTag
|
tags []*repoTag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tw *repoTags) Hidden() bool {
|
func (rs *RepoStatus) makeTagBox(box *gui.Node) {
|
||||||
return tw.window.Hidden()
|
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())
|
||||||
|
|
||||||
func (tw *repoTags) Show() {
|
// tagB.group.NewButton("prune tags", func() {
|
||||||
log.Info("tw *repoTags Show()")
|
// tagB.Prune()
|
||||||
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())
|
|
||||||
|
|
||||||
// tagW.group.NewButton("prune tags", func() {
|
|
||||||
// tagW.Prune()
|
|
||||||
// })
|
// })
|
||||||
var dups *gui.Node
|
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() {
|
dups.Custom = func() {
|
||||||
if dups.Checked() {
|
if dups.Checked() {
|
||||||
tagW.Prune()
|
tagB.Prune()
|
||||||
} else {
|
} else {
|
||||||
for _, t := range tagW.tags {
|
for _, t := range tagB.tags {
|
||||||
t.Show()
|
t.Show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tagW.group.NewButton("delete all", func() {
|
tagB.group.NewButton("delete all", func() {
|
||||||
for i, t := range tagW.tags {
|
for i, t := range tagB.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())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Info("tag is shown", i, t.tag.String())
|
log.Info("tag is shown", i, t.tag.String())
|
||||||
tagW.Delete(t)
|
rs.DeleteTag(t)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
grid := tagW.group.NewGrid("tags", 0, 0)
|
grid := tagB.group.NewGrid("tags", 0, 0)
|
||||||
tagW.grid = grid
|
tagB.grid = grid
|
||||||
|
|
||||||
grid.NewLabel("version")
|
grid.NewLabel("version")
|
||||||
grid.NewLabel("ref")
|
grid.NewLabel("ref")
|
||||||
|
@ -117,11 +90,11 @@ func (tagW *repoTags) newTagBox(box *gui.Node) {
|
||||||
// git rev-parse HEAD
|
// git rev-parse HEAD
|
||||||
// if last tag == HEAD, then remove it
|
// 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, "_,,,_")
|
format := strings.Join(tags, "_,,,_")
|
||||||
cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format}
|
cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format}
|
||||||
log.Info("RUNNING:", strings.Join(cmd, " "))
|
log.Info("RUNNING:", strings.Join(cmd, " "))
|
||||||
err, output := tagW.rs.RunCmd(cmd)
|
err, output := rs.RunCmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
output = "git error_,,,_a_,,,_b_,,,c"
|
output = "git error_,,,_a_,,,_b_,,,c"
|
||||||
}
|
}
|
||||||
|
@ -129,7 +102,7 @@ func (tagW *repoTags) newTagBox(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)
|
||||||
tagW.tags = make([]*repoTag, 0)
|
tagB.tags = make([]*repoTag, 0)
|
||||||
|
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
var parts []string
|
var parts []string
|
||||||
|
@ -143,7 +116,7 @@ func (tagW *repoTags) newTagBox(box *gui.Node) {
|
||||||
rTag.tag = grid.NewLabel(parts[0])
|
rTag.tag = grid.NewLabel(parts[0])
|
||||||
rTag.ref = grid.NewEntrybox(parts[1])
|
rTag.ref = grid.NewEntrybox(parts[1])
|
||||||
|
|
||||||
stamp, dur := getDateStamp(parts[2]) //
|
_, stamp, dur := getDateStamp(parts[2]) //
|
||||||
rTag.date = grid.NewLabel(stamp)
|
rTag.date = grid.NewLabel(stamp)
|
||||||
grid.NewLabel(dur)
|
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", "tag", "--delete", tagversion})
|
||||||
all = append(all, []string{"git", "push", "--delete", "origin", tagversion})
|
all = append(all, []string{"git", "push", "--delete", "origin", tagversion})
|
||||||
|
|
||||||
if tagW.rs.DoAll(all) {
|
if rs.DoAll(all) {
|
||||||
log.Info("TAG DELETED", tagW.rs.String(), tagversion)
|
log.Info("TAG DELETED", rs.String(), tagversion)
|
||||||
} else {
|
} 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
|
// works like a typerwriter
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
}
|
}
|
||||||
|
@ -170,7 +143,7 @@ func (tagW *repoTags) newTagBox(box *gui.Node) {
|
||||||
// slices.Reverse(rtags.tags)
|
// slices.Reverse(rtags.tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtags *repoTags) ListAll() []*repoTag {
|
func (rtags *gitTagBox) ListAll() []*repoTag {
|
||||||
var tags []*repoTag
|
var tags []*repoTag
|
||||||
for _, t := range rtags.tags {
|
for _, t := range rtags.tags {
|
||||||
tags = append(tags, t)
|
tags = append(tags, t)
|
||||||
|
@ -178,7 +151,7 @@ func (rtags *repoTags) ListAll() []*repoTag {
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtags *repoTags) List() []*repoTag {
|
func (rtags *gitTagBox) List() []*repoTag {
|
||||||
var tags []*repoTag
|
var tags []*repoTag
|
||||||
for _, t := range rtags.tags {
|
for _, t := range rtags.tags {
|
||||||
if t.hidden {
|
if t.hidden {
|
||||||
|
@ -191,7 +164,7 @@ func (rtags *repoTags) List() []*repoTag {
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtags *repoTags) Prune() {
|
func (rtags *gitTagBox) Prune() {
|
||||||
dups := make(map[string]*repoTag)
|
dups := make(map[string]*repoTag)
|
||||||
for i, t := range rtags.tags {
|
for i, t := range rtags.tags {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
|
@ -212,7 +185,7 @@ func (rtags *repoTags) Prune() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide tags worth keeping
|
// hide tags worth keeping
|
||||||
func (rtags *repoTags) PruneSmart() {
|
func (rtags *gitTagBox) PruneSmart() {
|
||||||
// always keep the first tag
|
// always keep the first tag
|
||||||
var first bool = true
|
var first bool = true
|
||||||
|
|
||||||
|
@ -265,9 +238,7 @@ func (rtags *repoTags) 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 (rtags *repoTags) Delete(rt *repoTag) {
|
func (rs *RepoStatus) DeleteTag(rt *repoTag) {
|
||||||
rs := rtags.rs
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
78
unix.go
78
unix.go
|
@ -119,6 +119,11 @@ func splitVersion(version string) (a, b, c string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) RunCmdEcho(parts []string) (error, string) {
|
||||||
|
log.Info("RunCmdEcho()", parts)
|
||||||
|
return rs.RunCmd(parts)
|
||||||
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) RunCmd(parts []string) (error, string) {
|
func (rs *RepoStatus) RunCmd(parts []string) (error, string) {
|
||||||
path := rs.realPath.String()
|
path := rs.realPath.String()
|
||||||
err, _, output := shell.RunCmd(path, parts)
|
err, _, output := shell.RunCmd(path, parts)
|
||||||
|
@ -269,22 +274,23 @@ func readFileToString(filename string) (string, error) {
|
||||||
return strings.TrimSpace(string(data)), nil
|
return strings.TrimSpace(string(data)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDateStamp(raw string) (string, string) {
|
func getDateStamp(raw string) (time.Time, string, string) {
|
||||||
parts := strings.Split(raw, " ")
|
parts := strings.Split(raw, " ")
|
||||||
if len(parts) == 0 {
|
if len(parts) == 0 {
|
||||||
// raw was blank here
|
// raw was blank here
|
||||||
return "Jan 4 1977", "40y" // eh, why not. it'll be easy to grep for this
|
// return "Jan 4 1977", "40y" // eh, why not. it'll be easy to grep for this
|
||||||
|
return time.Now(), "Jan 4 1977", "40y" // eh, why not. it'll be easy to grep for this
|
||||||
}
|
}
|
||||||
i, err := strconv.ParseInt(parts[0], 10, 64) // base 10 string, return int64
|
i, err := strconv.ParseInt(parts[0], 10, 64) // base 10 string, return int64
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Error converting timestamp:", raw)
|
log.Warn("Error converting timestamp:", raw)
|
||||||
log.Warn("Error converting timestamp err =", err)
|
log.Warn("Error converting timestamp err =", err)
|
||||||
return raw, ""
|
return time.Now(), "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the Unix timestamp into a time.Time object
|
// Parse the Unix timestamp into a time.Time object
|
||||||
gitTagDate := time.Unix(i, 0)
|
gitTagDate := time.Unix(i, 0)
|
||||||
return gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
|
return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDurationStamp(t time.Time) string {
|
func getDurationStamp(t time.Time) string {
|
||||||
|
@ -323,16 +329,18 @@ func formatDuration(d time.Duration) string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) XtermNohup(cmdline string) {
|
||||||
|
shell.XtermCmd(rs.Path(), []string{cmdline})
|
||||||
|
}
|
||||||
|
func (rs *RepoStatus) Xterm(cmdline string) {
|
||||||
|
shell.XtermCmd(rs.Path(), []string{cmdline})
|
||||||
|
}
|
||||||
|
func (rs *RepoStatus) XtermWait(cmdline string) {
|
||||||
|
shell.XtermCmdWait(rs.Path(), []string{cmdline})
|
||||||
|
}
|
||||||
|
/*
|
||||||
func (rs *RepoStatus) XtermNohup(args []string) {
|
func (rs *RepoStatus) XtermNohup(args []string) {
|
||||||
var argsX = []string{"xterm", "-geometry", "120x40"}
|
var argsX = []string{"xterm", "-geometry", "120x40"}
|
||||||
/*
|
|
||||||
if xtermHold.Checked() {
|
|
||||||
log.Println("hold = true")
|
|
||||||
argsXterm = append(argsXterm, "-hold")
|
|
||||||
} else {
|
|
||||||
log.Println("hold = false")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
argsX = append(argsX, "-e", "bash", "-c")
|
argsX = append(argsX, "-e", "bash", "-c")
|
||||||
argsX = append(argsX, args...)
|
argsX = append(argsX, args...)
|
||||||
log.Info("xterm cmd=", argsX)
|
log.Info("xterm cmd=", argsX)
|
||||||
|
@ -353,17 +361,11 @@ func (rs *RepoStatus) XtermNohup(args []string) {
|
||||||
log.Info("cmd =", argsX)
|
log.Info("cmd =", argsX)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
func (rs *RepoStatus) Xterm(args []string) {
|
func (rs *RepoStatus) Xterm(args []string) {
|
||||||
var argsX = []string{"-geometry", "120x40"}
|
var argsX = []string{"-geometry", "120x40"}
|
||||||
/*
|
|
||||||
if xtermHold.Checked() {
|
|
||||||
log.Println("hold = true")
|
|
||||||
argsXterm = append(argsXterm, "-hold")
|
|
||||||
} else {
|
|
||||||
log.Println("hold = false")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
argsX = append(argsX, "-e", "bash", "-c")
|
argsX = append(argsX, "-e", "bash", "-c")
|
||||||
argsX = append(argsX, args...)
|
argsX = append(argsX, args...)
|
||||||
log.Info("xterm cmd=", argsX)
|
log.Info("xterm cmd=", argsX)
|
||||||
|
@ -382,18 +384,36 @@ func (rs *RepoStatus) Xterm(args []string) {
|
||||||
log.Info("cmd = xterm", argsX)
|
log.Info("cmd = xterm", argsX)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
func (rs *RepoStatus) XtermHold(args []string) {
|
func (rs *RepoStatus) XtermHold(args []string) {
|
||||||
var argsX = []string{"-hold", "-geometry", "120x40"}
|
var argsX = []string{"-hold", "-geometry", "120x40"}
|
||||||
/*
|
tmp := strings.Join(args, " ") + ";bash"
|
||||||
if xtermHold.Checked() {
|
argsX = append(argsX, "-e", "bash", "-c", tmp)
|
||||||
log.Println("hold = true")
|
argsX = append(argsX, args...)
|
||||||
argsXterm = append(argsXterm, "-hold")
|
log.Info("xterm cmd=", argsX)
|
||||||
} else {
|
// set less to not exit on small diff's
|
||||||
log.Println("hold = false")
|
os.Setenv("LESS", "-+F -+X -R")
|
||||||
}
|
cmd := exec.Command("xterm", argsX...)
|
||||||
*/
|
path := rs.realPath.String()
|
||||||
argsX = append(argsX, "-e", "bash", "-c")
|
cmd.Dir = path
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
log.Info("xterm.Run() failed")
|
||||||
|
log.Info("path =", path)
|
||||||
|
log.Info("cmd = xterm", argsX)
|
||||||
|
} else {
|
||||||
|
log.Info("xterm.Run() worked")
|
||||||
|
log.Info("path =", path)
|
||||||
|
log.Info("cmd = xterm", argsX)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (rs *RepoStatus) XtermBash(args []string) {
|
||||||
|
var argsX = []string{"-geometry", "120x40"}
|
||||||
|
tmp := strings.Join(args, " ") + ";bash"
|
||||||
|
argsX = append(argsX, "-e", "bash", "-c", tmp)
|
||||||
argsX = append(argsX, args...)
|
argsX = append(argsX, args...)
|
||||||
log.Info("xterm cmd=", argsX)
|
log.Info("xterm cmd=", argsX)
|
||||||
// set less to not exit on small diff's
|
// set less to not exit on small diff's
|
||||||
|
|
Loading…
Reference in New Issue