cleaning up repostatus code
This commit is contained in:
parent
e323b15eb7
commit
bdb7617143
|
@ -0,0 +1,146 @@
|
|||
package main
|
||||
|
||||
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 addRepo(grid *gui.Node, path string, master string, devel string, user string) *repo {
|
||||
_, ok := me.allrepos[path]
|
||||
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() {
|
||||
me.reposwin.Disable()
|
||||
// newRepo.status.XtermNohup([]string{"git diff"})
|
||||
newRepo.status.Xterm("git diff; bash")
|
||||
me.reposwin.Enable()
|
||||
})
|
||||
|
||||
newRepo.endBox.NewButton("commit all", func() {
|
||||
me.reposwin.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.status.UpdateNew()
|
||||
newRepo.newScan()
|
||||
}
|
||||
me.reposwin.Enable()
|
||||
})
|
||||
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
me.allrepos[path] = newRepo
|
||||
return newRepo
|
||||
}
|
||||
|
||||
// deprecate this
|
||||
func (r *repo) String() string {
|
||||
return r.status.String()
|
||||
}
|
||||
|
||||
/*
|
||||
func (r *repo) getPath() string {
|
||||
return r.path
|
||||
}
|
||||
*/
|
|
@ -94,21 +94,31 @@ func globalBuildOptions(vbox *gui.Node) {
|
|||
// you can merge everything into the devel branch and make sure it actually
|
||||
// works. Then, when that is good, merge and version everything in master
|
||||
setBranchB = grid.NewButton("set current branch to:", func() {
|
||||
log.Warn("set current branch to:", newBranch.String())
|
||||
targetName := newBranch.String()
|
||||
log.Warn("set current branch to:", targetName)
|
||||
/*
|
||||
me.toMoveToBranch = guiBranch.String()
|
||||
setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
|
||||
me.mainBranch.Disable()
|
||||
*/
|
||||
for _, repo := range me.allrepos {
|
||||
if repo.status.CheckoutMaster() {
|
||||
log.Warn("set master branch worked", repo.String)
|
||||
if targetName == "jcarr" {
|
||||
if repo.status.CheckoutUser() {
|
||||
log.Warn("set master branch worked", repo.String())
|
||||
repo.newScan()
|
||||
} else {
|
||||
log.Warn("set master branch failed", repo.String)
|
||||
log.Warn("set master branch failed", repo.String())
|
||||
repo.newScan()
|
||||
}
|
||||
// return
|
||||
} else {
|
||||
if repo.status.CheckoutMaster() {
|
||||
log.Warn("set master branch worked", repo.String())
|
||||
repo.newScan()
|
||||
} else {
|
||||
log.Warn("set master branch failed", repo.String())
|
||||
repo.newScan()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
newBranch = grid.NewCombobox()
|
||||
|
|
2
main.go
2
main.go
|
@ -45,7 +45,7 @@ func main() {
|
|||
handleCmdLine()
|
||||
|
||||
for _, repo := range me.allrepos {
|
||||
repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
repo.newScan()
|
||||
}
|
||||
me.Enable()
|
||||
|
|
156
repolist.go
156
repolist.go
|
@ -13,7 +13,8 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (r *repo) String() string {
|
||||
// deprecate
|
||||
func (r *repo) StringOld() string {
|
||||
return r.status.String()
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,7 @@ func splitLine(line string) (string, string, string, string) {
|
|||
|
||||
func myrepolist() []string {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
cfgfile := filepath.Join(homeDir, ".config/myrepolist")
|
||||
cfgfile := filepath.Join(homeDir, ".config/autotypist")
|
||||
content, _ := ioutil.ReadFile(cfgfile)
|
||||
out := string(content)
|
||||
out = strings.TrimSpace(out)
|
||||
|
@ -52,141 +53,6 @@ func myrepolist() []string {
|
|||
return lines
|
||||
}
|
||||
|
||||
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 addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
||||
_, ok := me.allrepos[path]
|
||||
if ok {
|
||||
log.Info("addRepo() already had path", path)
|
||||
return
|
||||
}
|
||||
// log.Info("addRepo() attempting to add path", path)
|
||||
|
||||
newRepo := new(repo)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if strings.HasPrefix(path, "/") {
|
||||
// this is a direct path. don't check if it is a golang repo
|
||||
} else {
|
||||
if repostatus.VerifyLocalGoRepo(path) {
|
||||
// log.Verbose("newRepo actually exists", )
|
||||
} else {
|
||||
// log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path, master, devel, user)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
me.reposwin.Disable()
|
||||
// newRepo.status.XtermNohup([]string{"git diff"})
|
||||
newRepo.status.Xterm("git diff; bash")
|
||||
me.reposwin.Enable()
|
||||
})
|
||||
|
||||
newRepo.endBox.NewButton("commit all", func() {
|
||||
me.reposwin.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.status.Update()
|
||||
newRepo.newScan()
|
||||
}
|
||||
me.reposwin.Enable()
|
||||
})
|
||||
|
||||
newRepo.status = repostatus.NewRepoStatusWindow(path)
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
me.allrepos[path] = newRepo
|
||||
}
|
||||
|
||||
// This creates a window
|
||||
func repolistWindow() {
|
||||
me.reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
|
||||
|
@ -232,7 +98,11 @@ func repolistWindow() {
|
|||
if ubranch == "" {
|
||||
ubranch = usr.Username
|
||||
}
|
||||
addRepo(me.reposgrid, path, mbranch, dbranch, ubranch)
|
||||
newrepo := addRepo(me.reposgrid, path, mbranch, dbranch, ubranch)
|
||||
if newrepo != nil {
|
||||
// assume repos from ~/.config/autotypist file might be modified
|
||||
newrepo.status.Writable()
|
||||
}
|
||||
me.reposgrid.NextRow()
|
||||
}
|
||||
|
||||
|
@ -279,7 +149,7 @@ func repoAllButtons(box *gui.Node) {
|
|||
box1 := hbox.Box().Vertical()
|
||||
box1.NewButton("status.Update() all", func() {
|
||||
for _, repo := range me.allrepos {
|
||||
repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
repo.newScan()
|
||||
}
|
||||
})
|
||||
|
@ -352,14 +222,14 @@ func mergeAllDevelToMain() bool {
|
|||
continue
|
||||
}
|
||||
log.Info("found", repo.String(), repo.dirtyLabel.String())
|
||||
// repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
if repo.status.RunDevelMergeB() {
|
||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
||||
} else {
|
||||
log.Warn("THINGS FAILED fullAutomation() returned false")
|
||||
return false
|
||||
}
|
||||
repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
repo.newScan()
|
||||
}
|
||||
log.Warn("EVERYTHING WORKED")
|
||||
|
@ -382,14 +252,14 @@ func mergeAllUserToDevel() bool {
|
|||
continue
|
||||
}
|
||||
log.Info("found", repo.String(), repo.dirtyLabel.String())
|
||||
// repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
if repo.status.RunDevelMergeB() {
|
||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
||||
} else {
|
||||
log.Warn("THINGS FAILED fullAutomation() returned false")
|
||||
return false
|
||||
}
|
||||
repo.status.Update()
|
||||
repo.status.UpdateNew()
|
||||
repo.newScan()
|
||||
}
|
||||
log.Warn("EVERYTHING WORKED")
|
||||
|
|
|
@ -86,7 +86,6 @@ type autoType struct {
|
|||
|
||||
type repo struct {
|
||||
hidden bool
|
||||
// path string
|
||||
lasttagrev string
|
||||
lasttag string
|
||||
giturl string
|
||||
|
|
Loading…
Reference in New Issue