2024-02-17 08:39:55 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/gui/repostatus"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *Repo) Hide() {
|
|
|
|
r.pLabel.Hide()
|
|
|
|
r.lastTag.Hide()
|
|
|
|
r.vLabel.Hide()
|
|
|
|
|
|
|
|
r.masterVersion.Hide()
|
|
|
|
r.develVersion.Hide()
|
|
|
|
r.userVersion.Hide()
|
|
|
|
|
|
|
|
r.dirtyLabel.Hide()
|
|
|
|
r.endBox.Hide()
|
|
|
|
// r.statusButton.Hide()
|
|
|
|
// r.diffButton.Hide()
|
|
|
|
r.hidden = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repo) Hidden() bool {
|
|
|
|
return r.hidden
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repo) Show() {
|
|
|
|
r.pLabel.Show()
|
|
|
|
r.lastTag.Show()
|
|
|
|
r.vLabel.Show()
|
|
|
|
|
|
|
|
r.masterVersion.Show()
|
|
|
|
r.develVersion.Show()
|
|
|
|
r.userVersion.Show()
|
|
|
|
|
|
|
|
r.dirtyLabel.Show()
|
|
|
|
r.endBox.Show()
|
|
|
|
// r.statusButton.Show()
|
|
|
|
// r.diffButton.Show()
|
|
|
|
r.hidden = false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RepoList) AddRepo(path string, master string, devel string, user string) *Repo {
|
2024-02-17 14:22:24 -06:00
|
|
|
return r.addRepo(r.reposgrid, path, master, devel, user)
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
|
|
|
|
2024-02-17 14:22:24 -06:00
|
|
|
func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) *Repo {
|
|
|
|
_, ok := r.allrepos[path]
|
2024-02-17 08:39:55 -06:00
|
|
|
if ok {
|
|
|
|
log.Info("addRepo() already had path", path)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// log.Info("addRepo() attempting to add path", path)
|
|
|
|
rstatus := repostatus.NewRepoStatusWindow(path)
|
|
|
|
|
|
|
|
if rstatus == nil {
|
|
|
|
// log.Info("path isn't a repo I can figure out yet", path)
|
|
|
|
// probably this isn't downloaded
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
newRepo := new(Repo)
|
|
|
|
newRepo.status = rstatus
|
|
|
|
|
|
|
|
path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user
|
|
|
|
if path == "" {
|
|
|
|
// just an empty line in the config file
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
|
|
|
|
newRepo.lastTag = grid.NewLabel("").SetProgName("lastTag")
|
|
|
|
newRepo.masterVersion = grid.NewLabel("").SetProgName("masterVersion")
|
|
|
|
newRepo.develVersion = grid.NewLabel("").SetProgName("develVersion")
|
|
|
|
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
|
|
|
|
newRepo.dirtyLabel = grid.NewLabel("")
|
|
|
|
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
|
|
|
newRepo.endBox = grid.NewHorizontalBox("HBOX")
|
|
|
|
newRepo.endBox.NewButton("Configure", func() {
|
|
|
|
if newRepo.status == nil {
|
|
|
|
log.Warn("status window wasn't created")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
newRepo.status.Toggle()
|
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("show diff", func() {
|
2024-02-17 14:22:24 -06:00
|
|
|
r.reposbox.Disable()
|
2024-02-17 08:39:55 -06:00
|
|
|
// newRepo.status.XtermNohup([]string{"git diff"})
|
|
|
|
newRepo.status.Xterm("git diff; bash")
|
2024-02-17 14:22:24 -06:00
|
|
|
r.reposbox.Enable()
|
2024-02-17 08:39:55 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("commit all", func() {
|
2024-02-17 14:22:24 -06:00
|
|
|
r.reposbox.Disable()
|
2024-02-17 08:39:55 -06:00
|
|
|
// restore anything staged so everything can be reviewed
|
|
|
|
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."})
|
|
|
|
newRepo.status.XtermWait("git diff")
|
|
|
|
newRepo.status.XtermWait("git add --all")
|
|
|
|
newRepo.status.XtermWait("git commit -a")
|
|
|
|
newRepo.status.XtermWait("git push")
|
|
|
|
if newRepo.status.CheckDirty() {
|
|
|
|
// commit was not done, restore diff
|
|
|
|
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."})
|
|
|
|
} else {
|
2024-02-17 14:22:24 -06:00
|
|
|
newRepo.NewScan()
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
2024-02-17 14:22:24 -06:00
|
|
|
r.reposbox.Enable()
|
2024-02-17 08:39:55 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.hidden = false
|
|
|
|
// newRepo.status.SetMainWorkingName(master)
|
|
|
|
// newRepo.status.SetDevelWorkingName(devel)
|
|
|
|
// newRepo.status.SetUserWorkingName(user)
|
|
|
|
|
|
|
|
var showBuildB bool = false
|
|
|
|
switch newRepo.status.RepoType() {
|
|
|
|
case "binary":
|
|
|
|
// log.Info("compile here. Show()")
|
|
|
|
showBuildB = true
|
|
|
|
case "library":
|
|
|
|
// log.Info("library here. Hide()")
|
|
|
|
default:
|
|
|
|
// log.Info("unknown RepoType", newRepo.status.RepoType())
|
|
|
|
}
|
|
|
|
if showBuildB {
|
|
|
|
newRepo.endBox.NewButton("build", func() {
|
|
|
|
newRepo.status.Build()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
grid.NextRow()
|
|
|
|
|
2024-02-17 14:22:24 -06:00
|
|
|
r.allrepos[path] = newRepo
|
2024-02-17 08:39:55 -06:00
|
|
|
return newRepo
|
|
|
|
}
|