export Status

This commit is contained in:
Jeff Carr 2024-02-17 15:48:56 -06:00
parent b298958bcd
commit 985c422217
5 changed files with 55 additions and 91 deletions

View File

@ -64,7 +64,7 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
} }
newRepo := new(Repo) newRepo := new(Repo)
newRepo.status = rstatus newRepo.Status = rstatus
path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user
if path == "" { if path == "" {
@ -81,31 +81,31 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
newRepo.vLabel = grid.NewLabel("").SetProgName("current") newRepo.vLabel = grid.NewLabel("").SetProgName("current")
newRepo.endBox = grid.NewHorizontalBox("HBOX") newRepo.endBox = grid.NewHorizontalBox("HBOX")
newRepo.endBox.NewButton("Configure", func() { newRepo.endBox.NewButton("Configure", func() {
if newRepo.status == nil { if newRepo.Status == nil {
log.Warn("status window wasn't created") log.Warn("status window wasn't created")
return return
} }
newRepo.status.Toggle() newRepo.Status.Toggle()
}) })
newRepo.endBox.NewButton("show diff", func() { newRepo.endBox.NewButton("show diff", func() {
r.reposbox.Disable() r.reposbox.Disable()
// newRepo.status.XtermNohup([]string{"git diff"}) // newRepo.Status.XtermNohup([]string{"git diff"})
newRepo.status.Xterm("git diff; bash") newRepo.Status.Xterm("git diff; bash")
r.reposbox.Enable() r.reposbox.Enable()
}) })
newRepo.endBox.NewButton("commit all", func() { newRepo.endBox.NewButton("commit all", func() {
r.reposbox.Disable() r.reposbox.Disable()
// restore anything staged so everything can be reviewed // restore anything staged so everything can be reviewed
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."}) newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
newRepo.status.XtermWait("git diff") newRepo.Status.XtermWait("git diff")
newRepo.status.XtermWait("git add --all") newRepo.Status.XtermWait("git add --all")
newRepo.status.XtermWait("git commit -a") newRepo.Status.XtermWait("git commit -a")
newRepo.status.XtermWait("git push") newRepo.Status.XtermWait("git push")
if newRepo.status.CheckDirty() { if newRepo.Status.CheckDirty() {
// commit was not done, restore diff // commit was not done, restore diff
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."}) newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
} else { } else {
newRepo.NewScan() newRepo.NewScan()
} }
@ -113,23 +113,23 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
}) })
newRepo.hidden = false newRepo.hidden = false
// newRepo.status.SetMainWorkingName(master) // newRepo.Status.SetMainWorkingName(master)
// newRepo.status.SetDevelWorkingName(devel) // newRepo.Status.SetDevelWorkingName(devel)
// newRepo.status.SetUserWorkingName(user) // newRepo.Status.SetUserWorkingName(user)
var showBuildB bool = false var showBuildB bool = false
switch newRepo.status.RepoType() { switch newRepo.Status.RepoType() {
case "binary": case "binary":
// log.Info("compile here. Show()") // log.Info("compile here. Show()")
showBuildB = true showBuildB = true
case "library": case "library":
// log.Info("library here. Hide()") // log.Info("library here. Hide()")
default: default:
// log.Info("unknown RepoType", newRepo.status.RepoType()) // log.Info("unknown RepoType", newRepo.Status.RepoType())
} }
if showBuildB { if showBuildB {
newRepo.endBox.NewButton("build", func() { newRepo.endBox.NewButton("build", func() {
newRepo.status.Build() newRepo.Status.Build()
}) })
} }
grid.NextRow() grid.NextRow()

View File

@ -4,21 +4,6 @@ import (
"go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repostatus"
) )
// deprecate this
func (r *Repo) String() string {
return r.status.String()
}
// full path "/home/username/go/src/go.wit.com/apps/autotypist"
func (r *Repo) Path() string {
return r.status.Path()
}
// go path "go.wit.com/apps/autotypist"
func (r *Repo) GoPath() string {
return r.status.GoName()
}
func (r *RepoList) Hidden() bool { func (r *RepoList) Hidden() bool {
return r.reposbox.Hidden() return r.reposbox.Hidden()
} }
@ -48,55 +33,42 @@ func AllRepos() []*Repo {
return all return all
} }
func (r *Repo) Build() bool { // a human readable state of the current repo
return r.status.Build() func (r *Repo) State() string {
}
func (r *Repo) Xterm(s string) {
r.status.Xterm(s)
}
func (r *Repo) RepoType() string {
return r.status.RepoType()
}
func (r *Repo) Status() string {
return r.dirtyLabel.String() return r.dirtyLabel.String()
} }
func (r *Repo) MergeDevelToMaster() bool {
return r.status.MergeDevelToMaster()
}
func (r *Repo) MergeUserToDevel() bool {
return r.status.MergeUserToDevel()
}
func (r *Repo) Scan() bool { func (r *Repo) Scan() bool {
return r.NewScan() return r.NewScan()
} }
// returns a name for human consuption only
// todo: implement nicknames
func (rs *Repo) Name() string {
if rs.Status.IsGoLang() {
return rs.Status.GoPath()
}
return rs.Status.Path()
}
func (r *Repo) Exists(s string) bool { func (r *Repo) Exists(s string) bool {
return false return false
} }
func (r *Repo) MakeRedomod() { func (r *Repo) GoPath() string {
} return r.Status.GoPath()
func (r *Repo) CheckoutBranch(b string) bool {
return r.status.CheckoutBranch(b)
} }
func (r *Repo) CheckDirty() bool { func (r *Repo) CheckDirty() bool {
return r.status.CheckDirty() return r.Status.CheckDirty()
} }
func (r *Repo) IsDirty() bool { func (r *Repo) IsDirty() bool {
return r.status.IsDirty() return r.Status.IsDirty()
} }
func (r *Repo) ReadOnly() bool { func (r *Repo) ReadOnly() bool {
return r.status.ReadOnly() return r.Status.ReadOnly()
} }
func (r *Repo) IsPerfect() bool { func (r *Repo) IsPerfect() bool {
@ -110,27 +82,19 @@ func (r *Repo) IsPerfect() bool {
} }
func (r *Repo) RunCmd(cmd []string) (error, string) { func (r *Repo) RunCmd(cmd []string) (error, string) {
return r.status.RunCmd(cmd) return r.Status.RunCmd(cmd)
}
func (r *Repo) GetDevelBranchName() string {
return r.status.GetDevelBranchName()
}
func (r *Repo) GetUserBranchName() string {
return r.status.GetUserBranchName()
} }
func (r *Repo) AllTags() []*repostatus.Tag { func (r *Repo) AllTags() []*repostatus.Tag {
return r.status.Tags.ListAll() return r.Status.Tags.ListAll()
} }
func (r *Repo) TagsBox() *repostatus.GitTagBox { func (r *Repo) TagsBox() *repostatus.GitTagBox {
return r.status.Tags return r.Status.Tags
} }
// todo, fix bool return for deletetag() // todo, fix bool return for deletetag()
func (r *Repo) DeleteTag(t *repostatus.Tag) bool { func (r *Repo) DeleteTag(t *repostatus.Tag) bool {
r.status.DeleteTag(t) r.Status.DeleteTag(t)
return true return true
} }

2
new.go
View File

@ -27,7 +27,7 @@ func splitLine(line string) (string, string, string, string) {
func RepoType() { func RepoType() {
for _, repo := range me.allrepos { for _, repo := range me.allrepos {
switch repo.status.RepoType() { switch repo.Status.RepoType() {
case "binary": case "binary":
//log.Info("compile here. Show()") //log.Info("compile here. Show()")
repo.Show() repo.Show()

30
scan.go
View File

@ -26,48 +26,48 @@ func (r *RepoList) ScanRepositories() (int, string) {
} }
func (r *Repo) NewScan() bool { func (r *Repo) NewScan() bool {
if r.status == nil { if r.Status == nil {
log.Warn("repo.status = nil. not initialized for some reason") log.Warn("repo.Status = nil. not initialized for some reason")
return false return false
} }
// first run the repostatus update // first run the repostatus update
r.status.UpdateNew() r.Status.UpdateNew()
// now read those values and display them in our table // now read those values and display them in our table
mname := r.status.GetMasterBranchName() mname := r.Status.GetMasterBranchName()
mver := r.status.GetMasterVersion() mver := r.Status.GetMasterVersion()
mver = mver + " (" + mname + ")" mver = mver + " (" + mname + ")"
r.masterVersion.SetLabel(mver) r.masterVersion.SetLabel(mver)
dname := r.status.GetDevelBranchName() dname := r.Status.GetDevelBranchName()
dver := r.status.GetDevelVersion() dver := r.Status.GetDevelVersion()
if dname != "devel" { if dname != "devel" {
dver = dver + " (" + dname + ")" dver = dver + " (" + dname + ")"
} }
r.develVersion.SetLabel(dver) r.develVersion.SetLabel(dver)
uname := r.status.GetUserBranchName() uname := r.Status.GetUserBranchName()
uver := r.status.GetUserVersion() uver := r.Status.GetUserVersion()
usr, _ := user.Current() usr, _ := user.Current()
if uname != usr.Username { if uname != usr.Username {
uver = uver + " (" + uname + ")" uver = uver + " (" + uname + ")"
} }
r.userVersion.SetLabel(uver) r.userVersion.SetLabel(uver)
cbname := r.status.GetCurrentBranchName() cbname := r.Status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion() cbversion := r.Status.GetCurrentBranchVersion()
lasttag := r.status.GetLastTagVersion() lasttag := r.Status.GetLastTagVersion()
r.lastTag.SetLabel(lasttag) r.lastTag.SetLabel(lasttag)
r.vLabel.SetLabel(cbname + " " + cbversion) r.vLabel.SetLabel(cbname + " " + cbversion)
if c, ok := r.status.Changed(); ok { if c, ok := r.Status.Changed(); ok {
c := strings.TrimSpace(c) c := strings.TrimSpace(c)
for _, line := range strings.Split(c, "\n") { for _, line := range strings.Split(c, "\n") {
log.Info(r.status.Path(), line) log.Info(r.Status.Path(), line)
} }
} }
status := r.status.GetStatus() status := r.Status.GetStatus()
r.dirtyLabel.SetLabel(status) r.dirtyLabel.SetLabel(status)
if status == "PERFECT" { if status == "PERFECT" {
if me.autoHidePerfect { if me.autoHidePerfect {

View File

@ -50,5 +50,5 @@ type Repo struct {
statusButton *gui.Node // opens up the status window statusButton *gui.Node // opens up the status window
diffButton *gui.Node // opens up the status window diffButton *gui.Node // opens up the status window
status *repostatus.RepoStatus Status *repostatus.RepoStatus
} }