new Repo rewrite
This commit is contained in:
parent
3f29ea5ae7
commit
2975833e64
3
Makefile
3
Makefile
|
@ -1,5 +1,6 @@
|
|||
all:
|
||||
GO111MODULE=off go build
|
||||
@GO111MODULE=off go build
|
||||
@echo this go library package builds okay
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
|
208
addRepo.go
208
addRepo.go
|
@ -1,208 +0,0 @@
|
|||
package repolist
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"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.currentName.Hide()
|
||||
r.currentVersion.Hide()
|
||||
|
||||
r.masterVersion.Hide()
|
||||
r.develVersion.Hide()
|
||||
r.userVersion.Hide()
|
||||
|
||||
r.gitState.Hide()
|
||||
r.endBox.Hide()
|
||||
// r.statusButton.Hide()
|
||||
// r.diffButton.Hide()
|
||||
r.goState.Hide()
|
||||
r.targetV.Hide()
|
||||
r.hidden = true
|
||||
}
|
||||
|
||||
func (r *Repo) Hidden() bool {
|
||||
return r.hidden
|
||||
}
|
||||
|
||||
func (r *Repo) Show() {
|
||||
r.pLabel.Show()
|
||||
r.lastTag.Show()
|
||||
r.currentName.Show()
|
||||
r.currentVersion.Show()
|
||||
|
||||
r.masterVersion.Show()
|
||||
r.develVersion.Show()
|
||||
r.userVersion.Show()
|
||||
|
||||
r.gitState.Show()
|
||||
r.endBox.Show()
|
||||
// r.statusButton.Show()
|
||||
// r.diffButton.Show()
|
||||
r.goState.Show()
|
||||
r.targetV.Show()
|
||||
r.hidden = false
|
||||
}
|
||||
|
||||
func (r *RepoList) AddRepo(path string, master string, devel string, user string) (error, *Repo) {
|
||||
return r.addRepo(r.reposgrid, path, master, devel, user)
|
||||
}
|
||||
|
||||
func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) (error, *Repo) {
|
||||
existingr, ok := r.allrepos[path]
|
||||
if ok {
|
||||
log.Info("addRepo() already had path", path)
|
||||
return nil, existingr
|
||||
}
|
||||
// log.Info("addRepo() attempting to add path", path)
|
||||
err, rstatus := repostatus.NewRepoStatusWindow(path)
|
||||
|
||||
if rstatus == nil {
|
||||
log.Info("add failed. I can figure this out yet", path, err)
|
||||
// probably this isn't downloaded
|
||||
return err, 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 errors.New("you sent a blank path. stop being silly"), nil
|
||||
}
|
||||
|
||||
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
|
||||
newRepo.hidden = false
|
||||
switch r.viewName {
|
||||
case "autotypist":
|
||||
newRepo.lastTag = newRepo.Status.MirrorLastTag()
|
||||
grid.Append(newRepo.lastTag)
|
||||
|
||||
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)
|
||||
|
||||
newRepo.currentName = newRepo.Status.MirrorCurrentName()
|
||||
grid.Append(newRepo.currentName)
|
||||
newRepo.currentVersion = newRepo.Status.MirrorCurrentVersion()
|
||||
grid.Append(newRepo.currentVersion)
|
||||
|
||||
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
|
||||
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 {
|
||||
newRepo.NewScan()
|
||||
}
|
||||
r.reposbox.Enable()
|
||||
})
|
||||
|
||||
// newRepo.Status.SetMainWorkingName(master)
|
||||
// newRepo.Status.SetDevelWorkingName(devel)
|
||||
// newRepo.Status.SetUserWorkingName(user)
|
||||
|
||||
if strings.HasPrefix(newRepo.GoPath(), "go.wit.com/apps") {
|
||||
var showBuildB bool = false
|
||||
switch newRepo.Status.RepoType() {
|
||||
case "binary":
|
||||
log.Info("showing compile here button")
|
||||
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()
|
||||
})
|
||||
}
|
||||
}
|
||||
case "guireleaser":
|
||||
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)
|
||||
|
||||
newRepo.gitState = newRepo.Status.MirrorGitState()
|
||||
grid.Append(newRepo.gitState)
|
||||
|
||||
newRepo.goState = grid.NewLabel("goState")
|
||||
|
||||
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("CheckValidGoSum()", func() {
|
||||
ok, err := r.CheckValidGoSum(newRepo)
|
||||
if err != nil {
|
||||
log.Info("go mod tidy did not work err =", err)
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
newRepo.goState.SetText("GOOD")
|
||||
return
|
||||
}
|
||||
})
|
||||
default:
|
||||
}
|
||||
grid.NextRow()
|
||||
|
||||
r.allrepos[path] = newRepo
|
||||
newRepo.NewScan()
|
||||
return nil, newRepo
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package repolist
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (v *RepoList) InitRepoList(cfgfile string) {
|
||||
lines := parsecfg(cfgfile)
|
||||
for _, line := range lines {
|
||||
log.Verbose("repo =", line)
|
||||
line = strings.TrimSpace(line)
|
||||
if strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(line, " ")
|
||||
if len(parts) > 0 {
|
||||
path := parts[0]
|
||||
v.NewRepo(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parsecfg(f string) []string {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
cfgfile := filepath.Join(homeDir, f)
|
||||
content, _ := ioutil.ReadFile(cfgfile)
|
||||
out := string(content)
|
||||
out = strings.TrimSpace(out)
|
||||
lines := strings.Split(out, "\n")
|
||||
return lines
|
||||
}
|
42
newRepo.go
42
newRepo.go
|
@ -7,6 +7,48 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (r *Repo) Hidden() bool {
|
||||
return r.hidden
|
||||
}
|
||||
|
||||
func (r *Repo) Hide() {
|
||||
r.pLabel.Hide()
|
||||
r.lastTag.Hide()
|
||||
r.currentName.Hide()
|
||||
r.currentVersion.Hide()
|
||||
|
||||
r.masterVersion.Hide()
|
||||
r.develVersion.Hide()
|
||||
r.userVersion.Hide()
|
||||
|
||||
r.gitState.Hide()
|
||||
r.endBox.Hide()
|
||||
// r.statusButton.Hide()
|
||||
// r.diffButton.Hide()
|
||||
r.goState.Hide()
|
||||
r.targetV.Hide()
|
||||
r.hidden = true
|
||||
}
|
||||
|
||||
func (r *Repo) Show() {
|
||||
r.pLabel.Show()
|
||||
r.lastTag.Show()
|
||||
r.currentName.Show()
|
||||
r.currentVersion.Show()
|
||||
|
||||
r.masterVersion.Show()
|
||||
r.develVersion.Show()
|
||||
r.userVersion.Show()
|
||||
|
||||
r.gitState.Show()
|
||||
r.endBox.Show()
|
||||
// r.statusButton.Show()
|
||||
// r.diffButton.Show()
|
||||
r.goState.Show()
|
||||
r.targetV.Show()
|
||||
r.hidden = false
|
||||
}
|
||||
|
||||
func (r *RepoList) NewRepo(path string) (*Repo, error) {
|
||||
status, err := repostatus.New(path)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue