works and doesn't seem to crash

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-05 01:30:32 -06:00
parent 80d8dec89f
commit eefd7729a9
2 changed files with 61 additions and 21 deletions

View File

@ -94,26 +94,6 @@ func (r *RepoList) NewRepo(path string) (*RepoRow, error) {
return newRepo, nil
}
func (r *RepoList) ShowRepo(repo *RepoRow) error {
newRow := new(RepoRow)
newRow.pLabel = r.reposgrid.NewLabel(repo.Status.Path())
newRow.targetV = r.reposgrid.NewLabel(repo.Status.GetTargetVersion())
newRow.lastTag = r.reposgrid.NewLabel(repo.Status.LastTag())
newRow.currentName = r.reposgrid.NewLabel(repo.Status.GetCurrentBranchName())
newRow.currentVersion = r.reposgrid.NewLabel(repo.Status.GetCurrentVersion())
newRow.gitState = r.reposgrid.NewLabel(repo.Status.GitState())
newRow.masterVersion = r.reposgrid.NewLabel(repo.Status.GetMasterVersion())
newRow.develVersion = r.reposgrid.NewLabel(repo.Status.GetDevelVersion())
newRow.userVersion = r.reposgrid.NewLabel(repo.Status.GetUserVersion())
newRow.hidden = false
r.reposgrid.NextRow()
return nil
}
func (r *RepoList) makeAutotypistView(newRepo *RepoRow) {
grid := r.reposgrid

View File

@ -1,6 +1,9 @@
package repolist
import "go.wit.com/gui"
import (
"go.wit.com/gui"
"go.wit.com/log"
)
// This creates a view of the repos
// you can only have one at this point
@ -29,3 +32,60 @@ func TempWindowView(parent *gui.Node) *RepoList {
tmp.duration = me.blind.NewLabel("duration")
return tmp
}
func (r *RepoList) ShowRepo(repo *RepoRow) error {
// this is the gui grid. all the widgets get added here
// at the end we tell the grid go to NextRow()
grid := r.reposgrid
// make a new row of gui widgets
newRow := new(RepoRow)
newRow.Status = repo.Status
newRow.pLabel = grid.NewLabel(repo.Status.Path())
newRow.targetV = grid.NewLabel(repo.Status.GetTargetVersion())
newRow.lastTag = grid.NewLabel(repo.Status.LastTag())
newRow.currentName = grid.NewLabel(repo.Status.GetCurrentBranchName())
newRow.currentVersion = grid.NewLabel(repo.Status.GetCurrentVersion())
newRow.gitState = grid.NewLabel(repo.Status.GitState())
newRow.masterVersion = grid.NewLabel(repo.Status.GetMasterVersion())
newRow.develVersion = grid.NewLabel(repo.Status.GetDevelVersion())
newRow.userVersion = grid.NewLabel(repo.Status.GetUserVersion())
newRow.endBox = grid.NewHorizontalBox("HBOX")
newRow.endBox.NewButton("Repo Window", func() {
newRow.Status.Toggle()
})
newRow.endBox.NewButton("show diff", func() {
log.Log(REPOWARN, "show diff currentName =", newRow.currentName.String())
log.Log(REPOWARN, "show diff masterVersion =", newRow.masterVersion.String())
// newRow.Status.XtermNohup([]string{"git diff"})
newRow.Status.Xterm("git diff; bash")
})
newRow.endBox.NewButton("commit all", func() {
if !newRow.Status.IsUserBranch() {
log.Log(REPOWARN, "can not commit on non user branch")
return
}
// restore anything staged so everything can be reviewed
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
newRow.Status.XtermWait("git diff")
newRow.Status.XtermWait("git add --all")
newRow.Status.XtermWait("git commit -a")
newRow.Status.XtermWait("git push")
if newRow.Status.CheckDirty() {
// commit was not done, restore diff
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
} else {
newRow.NewScan()
}
})
newRow.hidden = false
r.reposgrid.NextRow()
return nil
}