2024-02-17 08:39:55 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
import (
|
2024-02-18 07:25:16 -06:00
|
|
|
"errors"
|
2024-02-17 08:39:55 -06:00
|
|
|
|
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/gui/repostatus"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *Repo) Hide() {
|
|
|
|
r.pLabel.Hide()
|
|
|
|
r.lastTag.Hide()
|
2024-02-19 14:42:34 -06:00
|
|
|
r.currentName.Hide()
|
|
|
|
r.currentVersion.Hide()
|
2024-02-17 08:39:55 -06:00
|
|
|
|
|
|
|
r.masterVersion.Hide()
|
|
|
|
r.develVersion.Hide()
|
|
|
|
r.userVersion.Hide()
|
|
|
|
|
2024-02-19 16:28:24 -06:00
|
|
|
r.gitState.Hide()
|
2024-02-17 08:39:55 -06:00
|
|
|
r.endBox.Hide()
|
|
|
|
// r.statusButton.Hide()
|
|
|
|
// r.diffButton.Hide()
|
2024-02-18 17:56:25 -06:00
|
|
|
r.goState.Hide()
|
|
|
|
r.targetV.Hide()
|
2024-02-17 08:39:55 -06:00
|
|
|
r.hidden = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repo) Hidden() bool {
|
|
|
|
return r.hidden
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repo) Show() {
|
|
|
|
r.pLabel.Show()
|
|
|
|
r.lastTag.Show()
|
2024-02-19 14:42:34 -06:00
|
|
|
r.currentName.Show()
|
|
|
|
r.currentVersion.Show()
|
2024-02-17 08:39:55 -06:00
|
|
|
|
|
|
|
r.masterVersion.Show()
|
|
|
|
r.develVersion.Show()
|
|
|
|
r.userVersion.Show()
|
|
|
|
|
2024-02-19 16:28:24 -06:00
|
|
|
r.gitState.Show()
|
2024-02-17 08:39:55 -06:00
|
|
|
r.endBox.Show()
|
|
|
|
// r.statusButton.Show()
|
|
|
|
// r.diffButton.Show()
|
2024-02-18 17:56:25 -06:00
|
|
|
r.goState.Show()
|
|
|
|
r.targetV.Show()
|
2024-02-17 08:39:55 -06:00
|
|
|
r.hidden = false
|
|
|
|
}
|
|
|
|
|
2024-02-18 07:25:16 -06:00
|
|
|
func (r *RepoList) AddRepo(path string, master string, devel string, user string) (error, *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-18 07:25:16 -06:00
|
|
|
func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) (error, *Repo) {
|
|
|
|
existingr, ok := r.allrepos[path]
|
2024-02-17 08:39:55 -06:00
|
|
|
if ok {
|
|
|
|
log.Info("addRepo() already had path", path)
|
2024-02-18 07:25:16 -06:00
|
|
|
return nil, existingr
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
|
|
|
// log.Info("addRepo() attempting to add path", path)
|
2024-02-18 07:25:16 -06:00
|
|
|
err, rstatus := repostatus.NewRepoStatusWindow(path)
|
2024-02-17 08:39:55 -06:00
|
|
|
|
|
|
|
if rstatus == nil {
|
2024-02-18 07:25:16 -06:00
|
|
|
log.Info("add failed. I can figure this out yet", path, err)
|
2024-02-17 08:39:55 -06:00
|
|
|
// probably this isn't downloaded
|
2024-02-18 07:25:16 -06:00
|
|
|
return err, nil
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
newRepo := new(Repo)
|
2024-02-17 15:48:56 -06:00
|
|
|
newRepo.Status = rstatus
|
2024-02-17 08:39:55 -06:00
|
|
|
|
2024-02-18 07:25:16 -06:00
|
|
|
// path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user
|
2024-02-17 08:39:55 -06:00
|
|
|
if path == "" {
|
|
|
|
// just an empty line in the config file
|
2024-02-18 07:25:16 -06:00
|
|
|
return errors.New("you sent a blank path. stop being silly"), nil
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
|
2024-02-18 10:49:52 -06:00
|
|
|
newRepo.hidden = false
|
|
|
|
switch r.viewName {
|
|
|
|
case "autotypist":
|
2024-02-19 14:42:34 -06:00
|
|
|
newRepo.lastTag = newRepo.Status.MirrorLastTag()
|
|
|
|
grid.Append(newRepo.lastTag)
|
2024-02-19 16:28:24 -06:00
|
|
|
|
|
|
|
newRepo.masterVersion = newRepo.Status.MirrorMasterVersion()
|
|
|
|
grid.Append(newRepo.masterVersion)
|
|
|
|
|
|
|
|
newRepo.develVersion = newRepo.Status.MirrorDevelVersion()
|
|
|
|
grid.Append(newRepo.develVersion)
|
|
|
|
|
|
|
|
newRepo.userVersion = newRepo.Status.MirrorUserVersion()
|
|
|
|
grid.Append(newRepo.userVersion)
|
|
|
|
|
|
|
|
newRepo.gitState = newRepo.Status.MirrorGitState()
|
|
|
|
grid.Append(newRepo.gitState)
|
2024-02-19 14:42:34 -06:00
|
|
|
|
|
|
|
newRepo.currentName = newRepo.Status.MirrorCurrentName()
|
|
|
|
grid.Append(newRepo.currentName)
|
|
|
|
newRepo.currentVersion = newRepo.Status.MirrorCurrentVersion()
|
|
|
|
grid.Append(newRepo.currentVersion)
|
|
|
|
|
2024-02-18 10:49:52 -06:00
|
|
|
newRepo.endBox = grid.NewHorizontalBox("HBOX")
|
|
|
|
newRepo.endBox.NewButton("Configure", func() {
|
|
|
|
if newRepo.Status == nil {
|
|
|
|
// this should never happen, but it does happen because I'm not that smart and forget I can nil Status
|
|
|
|
// for some reason that makes sense in my head. again, I'm not that smart
|
|
|
|
log.Warn("status window wasn't created")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
newRepo.Status.Toggle()
|
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("show diff", func() {
|
|
|
|
r.reposbox.Disable()
|
|
|
|
// newRepo.Status.XtermNohup([]string{"git diff"})
|
|
|
|
newRepo.Status.Xterm("git diff; bash")
|
|
|
|
r.reposbox.Enable()
|
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("commit all", func() {
|
|
|
|
r.reposbox.Disable()
|
|
|
|
// restore anything staged so everything can be reviewed
|
2024-02-17 15:48:56 -06:00
|
|
|
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
2024-02-18 10:49:52 -06:00
|
|
|
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 {
|
|
|
|
newRepo.NewScan()
|
|
|
|
}
|
|
|
|
r.reposbox.Enable()
|
|
|
|
})
|
|
|
|
|
|
|
|
// 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())
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
2024-02-18 10:49:52 -06:00
|
|
|
if showBuildB {
|
|
|
|
newRepo.endBox.NewButton("build", func() {
|
|
|
|
newRepo.Status.Build()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
case "guireleaser":
|
2024-02-19 14:42:34 -06:00
|
|
|
newRepo.targetV = newRepo.Status.MirrorTargetVersion()
|
|
|
|
grid.Append(newRepo.targetV)
|
|
|
|
|
|
|
|
newRepo.lastTag = newRepo.Status.MirrorLastTag()
|
|
|
|
grid.Append(newRepo.lastTag)
|
|
|
|
|
|
|
|
newRepo.currentName = newRepo.Status.MirrorCurrentName()
|
|
|
|
grid.Append(newRepo.currentName)
|
|
|
|
newRepo.currentVersion = newRepo.Status.MirrorCurrentVersion()
|
|
|
|
grid.Append(newRepo.currentVersion)
|
|
|
|
|
2024-02-19 16:28:24 -06:00
|
|
|
newRepo.gitState = newRepo.Status.MirrorGitState()
|
|
|
|
grid.Append(newRepo.gitState)
|
|
|
|
|
2024-02-20 06:53:42 -06:00
|
|
|
newRepo.goState = grid.NewLabel("goState")
|
2024-02-19 16:28:24 -06:00
|
|
|
|
2024-02-18 10:49:52 -06:00
|
|
|
newRepo.endBox = grid.NewHorizontalBox("HBOX")
|
|
|
|
newRepo.endBox.NewButton("Configure", func() {
|
|
|
|
if newRepo.Status == nil {
|
|
|
|
// this should never happen, but it does happen because I'm not that smart and forget I can nil Status
|
|
|
|
// for some reason that makes sense in my head. again, I'm not that smart
|
|
|
|
log.Warn("status window wasn't created")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
newRepo.Status.Toggle()
|
|
|
|
})
|
2024-02-17 08:39:55 -06:00
|
|
|
|
2024-02-18 10:49:52 -06:00
|
|
|
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()
|
|
|
|
})
|
|
|
|
}
|
2024-02-17 08:39:55 -06:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
grid.NextRow()
|
|
|
|
|
2024-02-17 14:22:24 -06:00
|
|
|
r.allrepos[path] = newRepo
|
2024-02-20 14:45:09 -06:00
|
|
|
newRepo.NewScan()
|
2024-02-18 07:25:16 -06:00
|
|
|
return nil, newRepo
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|