refactor to use repolist package
This commit is contained in:
parent
9cce297abf
commit
dfc28a04d6
145
addRepo.go
145
addRepo.go
|
@ -1,145 +0,0 @@
|
||||||
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.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
|
|
||||||
}
|
|
||||||
*/
|
|
7
docs.go
7
docs.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -27,12 +28,12 @@ func docsBox(vbox *gui.Node) {
|
||||||
fmt.Fprintln(f, "go 1.21.4")
|
fmt.Fprintln(f, "go 1.21.4")
|
||||||
fmt.Fprintln(f, "")
|
fmt.Fprintln(f, "")
|
||||||
fmt.Fprintln(f, "use (")
|
fmt.Fprintln(f, "use (")
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.status.Exists("go.mod") {
|
if repo.Exists("go.mod") {
|
||||||
fmt.Fprintln(f, "\t"+repo.String())
|
fmt.Fprintln(f, "\t"+repo.String())
|
||||||
} else {
|
} else {
|
||||||
log.Info("missing go.mod for", repo.String())
|
log.Info("missing go.mod for", repo.String())
|
||||||
repo.status.MakeRedomod()
|
repo.MakeRedomod()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Fprintln(f, ")")
|
fmt.Fprintln(f, ")")
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repostatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,9 +82,9 @@ func globalBuildOptions(vbox *gui.Node) {
|
||||||
me.setBranchB = grid.NewButton("set current branch to:", func() {
|
me.setBranchB = grid.NewButton("set current branch to:", func() {
|
||||||
targetName := me.newBranch.String()
|
targetName := me.newBranch.String()
|
||||||
log.Warn("setting all branches to", targetName)
|
log.Warn("setting all branches to", targetName)
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
repo.status.CheckoutBranch(targetName)
|
repo.CheckoutBranch(targetName)
|
||||||
repo.newScan()
|
repo.Scan()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
me.newBranch = grid.NewCombobox()
|
me.newBranch = grid.NewCombobox()
|
||||||
|
|
|
@ -5,23 +5,24 @@ import (
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gui/gowit"
|
"go.wit.com/lib/gui/gowit"
|
||||||
"go.wit.com/lib/gui/logsettings"
|
"go.wit.com/lib/gui/logsettings"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func globalDisplaySetRepoState() {
|
func globalDisplaySetRepoState() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.status.IsDirty() {
|
if repo.IsDirty() {
|
||||||
repo.Show()
|
repo.Show()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if me.autoHideReadOnly.Checked() {
|
if me.autoHideReadOnly.Checked() {
|
||||||
if repo.status.ReadOnly() {
|
if repo.ReadOnly() {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if me.autoHidePerfect.Checked() {
|
if me.autoHidePerfect.Checked() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.IsPerfect() {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -31,14 +32,14 @@ func globalDisplaySetRepoState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func globalDisplayShow() {
|
func globalDisplayShow() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if me.autoHideReadOnly.Checked() {
|
if me.autoHideReadOnly.Checked() {
|
||||||
if repo.status.ReadOnly() {
|
if repo.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if me.autoHidePerfect.Checked() {
|
if me.autoHidePerfect.Checked() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.IsPerfect() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,11 @@ func globalDisplayOptions(vbox *gui.Node) {
|
||||||
|
|
||||||
group1.NewButton("Show Repository Window", func() {
|
group1.NewButton("Show Repository Window", func() {
|
||||||
globalDisplaySetRepoState()
|
globalDisplaySetRepoState()
|
||||||
me.reposwin.Toggle()
|
if me.repoView.Hidden() {
|
||||||
|
me.repoView.Show()
|
||||||
|
} else {
|
||||||
|
me.repoView.Hide()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
||||||
|
@ -75,7 +80,7 @@ func globalDisplayOptions(vbox *gui.Node) {
|
||||||
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
|
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
|
||||||
scanbox.NewButton("scan now", func() {
|
scanbox.NewButton("scan now", func() {
|
||||||
log.Info("re-scanning repos now")
|
log.Info("re-scanning repos now")
|
||||||
scanRepositories()
|
repolist.ScanRepositories()
|
||||||
})
|
})
|
||||||
me.duration = scanbox.NewLabel("")
|
me.duration = scanbox.NewLabel("")
|
||||||
|
|
||||||
|
@ -115,9 +120,9 @@ func debuggerBox(vbox *gui.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func hidePerfect() {
|
func hidePerfect() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.IsPerfect() {
|
||||||
if repo.hidden {
|
if repo.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,8 +30,8 @@ func globalResetOptions(box *gui.Node) {
|
||||||
|
|
||||||
buildOptions.NewLabel("start over")
|
buildOptions.NewLabel("start over")
|
||||||
me.deleteGoSrcPkgB = buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() {
|
me.deleteGoSrcPkgB = buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.status.CheckDirty() {
|
if repo.CheckDirty() {
|
||||||
log.Warn("repo is dirty. commit your changes first", repo.String())
|
log.Warn("repo is dirty. commit your changes first", repo.String())
|
||||||
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)")
|
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)")
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,9 +19,9 @@ func argGitPull() bool {
|
||||||
me.autotypistWindow.Hide()
|
me.autotypistWindow.Hide()
|
||||||
cmd := []string{"git", "pull"}
|
cmd := []string{"git", "pull"}
|
||||||
var failed int = 0
|
var failed int = 0
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
log.Info("Running:", repo.String(), cmd)
|
log.Info("Running:", repo.String(), cmd)
|
||||||
err, output := repo.status.RunCmd(cmd)
|
err, output := repo.RunCmd(cmd)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info(output)
|
log.Info(output)
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,15 +39,15 @@ func argCheckoutDevel() bool {
|
||||||
log.Info("running git checkout devel everwhere")
|
log.Info("running git checkout devel everwhere")
|
||||||
me.autotypistWindow.Hide()
|
me.autotypistWindow.Hide()
|
||||||
var failed int = 0
|
var failed int = 0
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.status.CheckDirty() {
|
if repo.CheckDirty() {
|
||||||
log.Info("skipping dirty repo", repo.String())
|
log.Info("skipping dirty repo", repo.String())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
branch := repo.status.GetDevelBranchName()
|
branch := repo.GetDevelBranchName()
|
||||||
cmd := []string{"git", "checkout", branch}
|
cmd := []string{"git", "checkout", branch}
|
||||||
log.Info("Running:", cmd, "in", repo.String())
|
log.Info("Running:", cmd, "in", repo.String())
|
||||||
err, output := repo.status.RunCmd(cmd)
|
err, output := repo.RunCmd(cmd)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info("git checkout worked", output)
|
log.Info("git checkout worked", output)
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,15 +66,15 @@ func argCheckoutUser() bool {
|
||||||
log.Info("running git checkout devel everwhere")
|
log.Info("running git checkout devel everwhere")
|
||||||
me.autotypistWindow.Hide()
|
me.autotypistWindow.Hide()
|
||||||
var failed int = 0
|
var failed int = 0
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.status.CheckDirty() {
|
if repo.CheckDirty() {
|
||||||
log.Info("skipping dirty repo", repo.String())
|
log.Info("skipping dirty repo", repo.String())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
branch := repo.status.GetUserBranchName()
|
branch := repo.GetUserBranchName()
|
||||||
cmd := []string{"git", "checkout", branch}
|
cmd := []string{"git", "checkout", branch}
|
||||||
log.Info("Running:", cmd, "in", repo.String())
|
log.Info("Running:", cmd, "in", repo.String())
|
||||||
err, output := repo.status.RunCmd(cmd)
|
err, output := repo.RunCmd(cmd)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info("git checkout worked", output)
|
log.Info("git checkout worked", output)
|
||||||
} else {
|
} else {
|
||||||
|
|
63
main.go
63
main.go
|
@ -2,9 +2,12 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"time"
|
"os/user"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
|
"go.wit.com/lib/gui/repostatus"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
@ -15,7 +18,6 @@ var resToolkit embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(autoType)
|
me = new(autoType)
|
||||||
me.allrepos = make(map[string]*repo)
|
|
||||||
|
|
||||||
me.myGui = gui.New()
|
me.myGui = gui.New()
|
||||||
me.myGui.InitEmbed(resToolkit)
|
me.myGui.InitEmbed(resToolkit)
|
||||||
|
@ -39,52 +41,31 @@ func main() {
|
||||||
|
|
||||||
globalResetOptions(me.mainbox)
|
globalResetOptions(me.mainbox)
|
||||||
|
|
||||||
repolistWindow()
|
me.repoView = repolist.AutotypistView()
|
||||||
|
|
||||||
|
usr, _ := user.Current()
|
||||||
|
if args.OnlyMe {
|
||||||
|
log.Info("not scanning everything")
|
||||||
|
} else {
|
||||||
|
log.Info("scanning everything in ~/go/src")
|
||||||
|
for i, path := range repostatus.ListGitDirectories() {
|
||||||
|
// log.Info("addRepo()", i, path)
|
||||||
|
path = strings.TrimPrefix(path, me.goSrcPwd.String())
|
||||||
|
path = strings.Trim(path, "/")
|
||||||
|
log.Info("addRepo()", i, path)
|
||||||
|
me.repoView.AddRepo(path, "master", "devel", usr.Username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// process everything on the command line
|
// process everything on the command line
|
||||||
handleCmdLine()
|
handleCmdLine()
|
||||||
|
|
||||||
for _, repo := range me.allrepos {
|
repolist.ScanRepositories()
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
me.Enable()
|
me.Enable()
|
||||||
|
|
||||||
// processing is done. update the repo summary box
|
// processing is done. update the repo summary box
|
||||||
me.summary.Update()
|
me.summary.Update()
|
||||||
|
|
||||||
// scan repos every i seconds
|
// intermittently scans the status indefinitly
|
||||||
// check every 'delay seconds for the checkbox changing
|
repolist.Watchdog()
|
||||||
// this logic is unintuitive because I want it to fluidly
|
|
||||||
// never tricker quickly but also want to print something
|
|
||||||
// out that the app is alive since, technically
|
|
||||||
// the GUI is *NOT* this app and could be alive when
|
|
||||||
// the application is actually stalled somewhere
|
|
||||||
// plus these things are fun for me and a distraction when
|
|
||||||
// I've been working 50 days in a row on this gui code
|
|
||||||
|
|
||||||
// this also means that if you click the checkbox after
|
|
||||||
// the delay, then the scan will run right away, but if
|
|
||||||
// you check the checkbox twice in 5 seconds, it won't
|
|
||||||
// rerun until the delay again
|
|
||||||
var delay int = 99
|
|
||||||
var i int = delay
|
|
||||||
myTicker(1*time.Second, "newScan()", func() {
|
|
||||||
i += 1
|
|
||||||
// check if the checkbox is checked
|
|
||||||
if !me.autoScanReposCB.Checked() {
|
|
||||||
if i < delay {
|
|
||||||
i = delay
|
|
||||||
}
|
|
||||||
// print every 'delay' seconds
|
|
||||||
if i%delay == 0 {
|
|
||||||
log.Info("Not auto scanning", i)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if i < delay {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
i = 0
|
|
||||||
scanRepositories()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
259
repolist.go
259
repolist.go
|
@ -1,259 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/repostatus"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
// deprecate
|
|
||||||
func (r *repo) StringOld() string {
|
|
||||||
return r.status.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
func (r *repo) getPath() string {
|
|
||||||
return r.path
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func RemoveFirstElement(slice []string) (string, []string) {
|
|
||||||
if len(slice) == 0 {
|
|
||||||
return "", slice // Return the original slice if it's empty
|
|
||||||
}
|
|
||||||
return slice[0], slice[1:] // Return the slice without the first element
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns path, master branch name, devel branch name, user branch name
|
|
||||||
func splitLine(line string) (string, string, string, string) {
|
|
||||||
var path, master, devel, user string
|
|
||||||
parts := strings.Split(line, " ")
|
|
||||||
path, parts = RemoveFirstElement(parts)
|
|
||||||
master, parts = RemoveFirstElement(parts)
|
|
||||||
devel, parts = RemoveFirstElement(parts)
|
|
||||||
user, parts = RemoveFirstElement(parts)
|
|
||||||
// path, master, devel, user := strings.Split(line, " ")
|
|
||||||
return path, master, devel, user
|
|
||||||
}
|
|
||||||
|
|
||||||
func myrepolist() []string {
|
|
||||||
homeDir, _ := os.UserHomeDir()
|
|
||||||
cfgfile := filepath.Join(homeDir, ".config/autotypist")
|
|
||||||
content, _ := ioutil.ReadFile(cfgfile)
|
|
||||||
out := string(content)
|
|
||||||
out = strings.TrimSpace(out)
|
|
||||||
lines := strings.Split(out, "\n")
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
// This creates a window
|
|
||||||
func repolistWindow() {
|
|
||||||
me.reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
|
|
||||||
me.reposwin.Make()
|
|
||||||
|
|
||||||
me.reposbox = me.reposwin.Box().NewBox("bw vbox", false)
|
|
||||||
// me.reposwin.Draw()
|
|
||||||
me.reposwin.Custom = func() {
|
|
||||||
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
|
||||||
log.Warn("Should I do something special here?")
|
|
||||||
}
|
|
||||||
|
|
||||||
repoAllButtons(me.reposbox)
|
|
||||||
|
|
||||||
me.reposgroup = me.reposbox.NewGroup("git repositories (configure in ~/.config/myrepolist)")
|
|
||||||
me.reposgrid = me.reposgroup.NewGrid("test", 0, 0)
|
|
||||||
|
|
||||||
me.reposgrid.NewLabel("") // path goes here
|
|
||||||
|
|
||||||
me.reposgrid.NewLabel("last tag").SetProgName("last tag")
|
|
||||||
|
|
||||||
me.reposgrid.NewLabel("master version")
|
|
||||||
me.reposgrid.NewLabel("devel version")
|
|
||||||
me.reposgrid.NewLabel("user version")
|
|
||||||
|
|
||||||
me.reposgrid.NewLabel("Status")
|
|
||||||
|
|
||||||
me.reposgrid.NewLabel("Current Version").SetProgName("Current Version")
|
|
||||||
me.reposgrid.NextRow()
|
|
||||||
|
|
||||||
usr, _ := user.Current()
|
|
||||||
|
|
||||||
repos := myrepolist()
|
|
||||||
for _, line := range repos {
|
|
||||||
log.Verbose("repo =", line)
|
|
||||||
path, mbranch, dbranch, ubranch := splitLine(line)
|
|
||||||
if mbranch == "" {
|
|
||||||
mbranch = "master"
|
|
||||||
}
|
|
||||||
if dbranch == "" {
|
|
||||||
dbranch = "devel"
|
|
||||||
}
|
|
||||||
if ubranch == "" {
|
|
||||||
ubranch = usr.Username
|
|
||||||
}
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.OnlyMe {
|
|
||||||
log.Info("not scanning everything")
|
|
||||||
} else {
|
|
||||||
log.Info("scanning everything in ~/go/src")
|
|
||||||
for i, path := range repostatus.ListGitDirectories() {
|
|
||||||
// log.Info("addRepo()", i, path)
|
|
||||||
tmp := strings.TrimPrefix(path, me.goSrcPwd.String())
|
|
||||||
path = strings.Trim(tmp, "/")
|
|
||||||
log.Info("addRepo()", i, path)
|
|
||||||
addRepo(me.reposgrid, path, "master", "devel", usr.Username)
|
|
||||||
me.reposgrid.NextRow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func showApps() {
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
switch repo.status.RepoType() {
|
|
||||||
case "binary":
|
|
||||||
//log.Info("compile here. Show()")
|
|
||||||
repo.Show()
|
|
||||||
case "library":
|
|
||||||
//log.Info("library here. Hide()")
|
|
||||||
repo.Hide()
|
|
||||||
default:
|
|
||||||
log.Info("showApps() unknown. Show()")
|
|
||||||
repo.Hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func repoAllButtons(box *gui.Node) {
|
|
||||||
// reposbox.SetExpand(false)
|
|
||||||
group1 := box.NewGroup("Run on all repos:")
|
|
||||||
|
|
||||||
hbox := group1.Box()
|
|
||||||
// hbox.Horizontal()
|
|
||||||
hbox.Vertical()
|
|
||||||
|
|
||||||
box2 := hbox.Box().Vertical()
|
|
||||||
box2.NewButton("merge all user to devel", func() {
|
|
||||||
me.reposwin.Disable()
|
|
||||||
if !mergeAllUserToDevel() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.reposwin.Enable()
|
|
||||||
})
|
|
||||||
|
|
||||||
box2.NewButton("merge all devel to main", func() {
|
|
||||||
me.reposwin.Disable()
|
|
||||||
if !mergeAllDevelToMain() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.reposwin.Enable()
|
|
||||||
})
|
|
||||||
|
|
||||||
box2.NewButton("merge it all", func() {
|
|
||||||
me.reposwin.Disable()
|
|
||||||
if !mergeAllUserToDevel() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !mergeAllDevelToMain() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.reposwin.Enable()
|
|
||||||
})
|
|
||||||
|
|
||||||
box2.NewButton("test all builds", func() {
|
|
||||||
me.reposwin.Disable()
|
|
||||||
defer me.reposwin.Enable()
|
|
||||||
showApps()
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
if repo.Hidden() {
|
|
||||||
// log.Info("skip hidden", repo.String())
|
|
||||||
} else {
|
|
||||||
log.Info("try to build", repo.String())
|
|
||||||
if repo.status.Build() {
|
|
||||||
log.Info("build worked", repo.String())
|
|
||||||
} else {
|
|
||||||
log.Info("build failed", repo.String())
|
|
||||||
go repo.status.Xterm("bash")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Info("")
|
|
||||||
log.Info("every build worked !!!")
|
|
||||||
log.Info("")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeAllDevelToMain() bool {
|
|
||||||
log.Info("merge all here")
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
if repo.status.ReadOnly() {
|
|
||||||
log.Info("skipping readonly", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if repo.dirtyLabel.String() != "merge to main" {
|
|
||||||
log.Info("skipping. not merge to main", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if repo.status.CheckDirty() {
|
|
||||||
log.Info("skipping dirty", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Info("found", repo.String(), repo.dirtyLabel.String())
|
|
||||||
repo.newScan()
|
|
||||||
if repo.status.MergeDevelToMaster() {
|
|
||||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
||||||
} else {
|
|
||||||
log.Warn("last repo:", repo.status.Path())
|
|
||||||
log.Warn("THINGS FAILED fullAutomation() returned false")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
log.Warn("EVERYTHING WORKED")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeAllUserToDevel() bool {
|
|
||||||
log.Info("merge all here")
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
if repo.status.ReadOnly() {
|
|
||||||
log.Info("skipping readonly", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if repo.dirtyLabel.String() != "merge to devel" {
|
|
||||||
log.Info("skipping. not merge to devel", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if repo.status.CheckDirty() {
|
|
||||||
log.Info("skipping dirty", repo.String(), repo.dirtyLabel.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Info("found", repo.String(), repo.dirtyLabel.String())
|
|
||||||
repo.newScan()
|
|
||||||
if repo.status.MergeUserToDevel() {
|
|
||||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
||||||
} else {
|
|
||||||
log.Warn("last repo:", repo.status.Path())
|
|
||||||
log.Warn("THINGS FAILED fullAutomation() returned false")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
log.Warn("EVERYTHING WORKED")
|
|
||||||
return true
|
|
||||||
}
|
|
103
scan.go
103
scan.go
|
@ -1,103 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os/user"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func scanRepositories() {
|
|
||||||
log.Info("Scanned", me.summary.totalOL.String(), "repositories. todo: count/show changes")
|
|
||||||
t := timeFunction(func() {
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
s := fmt.Sprint(t)
|
|
||||||
me.duration.SetText(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) newScan() bool {
|
|
||||||
if r.status == nil {
|
|
||||||
log.Warn("repo.status = nil. not initialized for some reason")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// first run the repostatus update
|
|
||||||
r.status.UpdateNew()
|
|
||||||
|
|
||||||
// now read those values and display them in our table
|
|
||||||
mname := r.status.GetMasterBranchName()
|
|
||||||
mver := r.status.GetMasterVersion()
|
|
||||||
mver = mver + " (" + mname + ")"
|
|
||||||
r.masterVersion.SetLabel(mver)
|
|
||||||
|
|
||||||
dname := r.status.GetDevelBranchName()
|
|
||||||
dver := r.status.GetDevelVersion()
|
|
||||||
if dname != "devel" {
|
|
||||||
dver = dver + " (" + dname + ")"
|
|
||||||
}
|
|
||||||
r.develVersion.SetLabel(dver)
|
|
||||||
|
|
||||||
uname := r.status.GetUserBranchName()
|
|
||||||
uver := r.status.GetUserVersion()
|
|
||||||
usr, _ := user.Current()
|
|
||||||
if uname != usr.Username {
|
|
||||||
uver = uver + " (" + uname + ")"
|
|
||||||
}
|
|
||||||
r.userVersion.SetLabel(uver)
|
|
||||||
|
|
||||||
cbname := r.status.GetCurrentBranchName()
|
|
||||||
cbversion := r.status.GetCurrentBranchVersion()
|
|
||||||
lasttag := r.status.GetLastTagVersion()
|
|
||||||
r.lastTag.SetLabel(lasttag)
|
|
||||||
r.vLabel.SetLabel(cbname + " " + cbversion)
|
|
||||||
|
|
||||||
if c, ok := r.status.Changed(); ok {
|
|
||||||
c := strings.TrimSpace(c)
|
|
||||||
for _, line := range strings.Split(c, "\n") {
|
|
||||||
log.Info(r.status.Path(), line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status := r.status.GetStatus()
|
|
||||||
r.dirtyLabel.SetLabel(status)
|
|
||||||
if status == "PERFECT" {
|
|
||||||
if me.autoHidePerfect.Checked() {
|
|
||||||
r.Hide()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// timeFunction takes a function as an argument and returns the execution time.
|
|
||||||
func timeFunction(f func()) time.Duration {
|
|
||||||
startTime := time.Now() // Record the start time
|
|
||||||
f() // Execute the function
|
|
||||||
return time.Since(startTime) // Calculate the elapsed time
|
|
||||||
}
|
|
||||||
|
|
||||||
func myTicker(t time.Duration, name string, f func()) {
|
|
||||||
ticker := time.NewTicker(t)
|
|
||||||
defer ticker.Stop()
|
|
||||||
done := make(chan bool)
|
|
||||||
/*
|
|
||||||
go func() {
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
done <- true
|
|
||||||
}()
|
|
||||||
*/
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
fmt.Println("Done!")
|
|
||||||
return
|
|
||||||
case t := <-ticker.C:
|
|
||||||
log.Verbose(name, "Current time: ", t)
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
13
structs.go
13
structs.go
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repolist"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *autoType
|
var me *autoType
|
||||||
|
@ -18,20 +18,19 @@ func (b *autoType) Enable() {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type autoType struct {
|
type autoType struct {
|
||||||
allrepos map[string]*repo
|
// allrepos map[string]*repo
|
||||||
myGui *gui.Node
|
myGui *gui.Node
|
||||||
|
|
||||||
autotypistWindow *gui.Node
|
autotypistWindow *gui.Node
|
||||||
|
|
||||||
// the main box. enable/disable this
|
// the main box. enable/disable this
|
||||||
mainbox *gui.Node
|
mainbox *gui.Node
|
||||||
|
|
||||||
// the window from the /lib/gui/gowit package
|
// the window from the /lib/gui/gowit package
|
||||||
lw *gadgets.BasicWindow
|
lw *gadgets.BasicWindow
|
||||||
|
|
||||||
reposwin *gadgets.BasicWindow
|
// our view of the repositories
|
||||||
reposbox *gui.Node
|
repoView *repolist.RepoList
|
||||||
reposgrid *gui.Node
|
|
||||||
reposgroup *gui.Node
|
|
||||||
|
|
||||||
// #### autotypist Global Display Options
|
// #### autotypist Global Display Options
|
||||||
autoHidePerfect *gui.Node
|
autoHidePerfect *gui.Node
|
||||||
|
@ -88,6 +87,7 @@ type autoType struct {
|
||||||
setBranchB *gui.Node
|
setBranchB *gui.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
type repo struct {
|
type repo struct {
|
||||||
hidden bool
|
hidden bool
|
||||||
lasttagrev string
|
lasttagrev string
|
||||||
|
@ -111,3 +111,4 @@ type repo struct {
|
||||||
|
|
||||||
status *repostatus.RepoStatus
|
status *repostatus.RepoStatus
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -3,11 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/gowit"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repostatus"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -58,10 +57,10 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
s.gitPullB = s.grid.NewButton("git pull", func() {
|
s.gitPullB = s.grid.NewButton("git pull", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
// gitcmd := []string{"git", "fetch", "origin"}
|
// gitcmd := []string{"git", "fetch", "origin"}
|
||||||
gitcmd := []string{"git", "pull"}
|
gitcmd := []string{"git", "pull"}
|
||||||
err, output := repo.status.RunCmd(gitcmd)
|
err, output := repo.RunCmd(gitcmd)
|
||||||
log.Info("output =", output)
|
log.Info("output =", output)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info("git fetch worked", repo.String())
|
log.Info("git fetch worked", repo.String())
|
||||||
|
@ -78,9 +77,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
s.gitPushB = s.grid.NewButton("git push", func() {
|
s.gitPushB = s.grid.NewButton("git push", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
gitcmd := []string{"git", "push"}
|
gitcmd := []string{"git", "push"}
|
||||||
err, output := repo.status.RunCmd(gitcmd)
|
err, output := repo.RunCmd(gitcmd)
|
||||||
log.Info("output =", output)
|
log.Info("output =", output)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info("git push worked", repo.String())
|
log.Info("git push worked", repo.String())
|
||||||
|
@ -95,19 +94,20 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
})
|
})
|
||||||
|
|
||||||
s.checkB = s.grid.NewButton("Check repos are working", func() {
|
s.checkB = s.grid.NewButton("Check repos are working", func() {
|
||||||
|
/*
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.giturl != "" {
|
if repo.GitURL() != "" {
|
||||||
log.Info("repo already checked. do they match?", repo.String())
|
log.Info("repo already checked. do they match?")
|
||||||
log.Info("go.wit.com =", repo.giturl)
|
log.Info("go.wit.com =", repo.GoURL())
|
||||||
log.Info("localurl =", repo.status.GitURL())
|
log.Info("localurl =", repo.Path())
|
||||||
} else {
|
} else {
|
||||||
ok, giturl := gowit.CheckRegistered(repo.status)
|
ok, giturl := gowit.CheckRegistered(repo)
|
||||||
if ok {
|
if ok {
|
||||||
log.Info("is url correct?", repo.String(), "vs", giturl)
|
log.Info("is url correct?", repo.Path(), "vs", giturl)
|
||||||
repo.giturl = giturl
|
repo.giturl = giturl
|
||||||
if giturl != repo.status.GitURL() {
|
if giturl != repo.Path() {
|
||||||
log.Info("repo check failed", repo.String())
|
log.Info("repo check failed", repo.String())
|
||||||
s.unknownOL.SetText(repo.String())
|
s.unknownOL.SetText(repo.String())
|
||||||
s.unknownOL.Show()
|
s.unknownOL.Show()
|
||||||
|
@ -125,14 +125,15 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.checkB.SetText("GOOD")
|
s.checkB.SetText("GOOD")
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
s.grid.NextRow()
|
s.grid.NextRow()
|
||||||
|
|
||||||
s.unknownOL = gadgets.NewOneLiner(s.grid, "Unknown Repo:")
|
s.unknownOL = gadgets.NewOneLiner(s.grid, "Unknown Repo:")
|
||||||
s.unknownSubmitB = s.grid.NewButton("Register Repo", func() {
|
s.unknownSubmitB = s.grid.NewButton("Register Repo", func() {
|
||||||
|
/*
|
||||||
log.Info("Submit repo:", s.unknownOL.String())
|
log.Info("Submit repo:", s.unknownOL.String())
|
||||||
repo, ok := me.allrepos[s.unknownOL.String()]
|
if repolist.Exists(s.unknownOL.String()) {
|
||||||
if ok {
|
|
||||||
log.Info("found repo:", repo.String(), "with giturl", repo.giturl)
|
log.Info("found repo:", repo.String(), "with giturl", repo.giturl)
|
||||||
localurl := repo.status.GitURL()
|
localurl := repo.status.GitURL()
|
||||||
if localurl == "" {
|
if localurl == "" {
|
||||||
|
@ -148,6 +149,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
} else {
|
} else {
|
||||||
log.Info("what is this?", s.unknownOL.String())
|
log.Info("what is this?", s.unknownOL.String())
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
s.unknownOL.Hide()
|
s.unknownOL.Hide()
|
||||||
s.unknownSubmitB.Hide()
|
s.unknownSubmitB.Hide()
|
||||||
|
@ -185,8 +187,8 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
log.Info("something went wrong making", patchdir)
|
log.Info("something went wrong making", patchdir)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if makePatchset(patchdir) {
|
// if makePatchset(patchdir) {
|
||||||
}
|
// }
|
||||||
})
|
})
|
||||||
// disable these until there are not dirty repos
|
// disable these until there are not dirty repos
|
||||||
s.reason.Disable()
|
s.reason.Disable()
|
||||||
|
@ -197,9 +199,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
|
|
||||||
func (s *patchSummary) Update() {
|
func (s *patchSummary) Update() {
|
||||||
var total, dirty, readonly int
|
var total, dirty, readonly int
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
total += 1
|
total += 1
|
||||||
if repo.status.CheckDirty() {
|
if repo.IsDirty() {
|
||||||
if repo.String() == "go.wit.com/apps/autotypist" {
|
if repo.String() == "go.wit.com/apps/autotypist" {
|
||||||
// log.Info("ignoring dirty autotypist for now")
|
// log.Info("ignoring dirty autotypist for now")
|
||||||
dirty += 1
|
dirty += 1
|
||||||
|
@ -207,7 +209,7 @@ func (s *patchSummary) Update() {
|
||||||
dirty += 1
|
dirty += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if repo.status.ReadOnly() {
|
if repo.ReadOnly() {
|
||||||
readonly += 1
|
readonly += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,6 +217,7 @@ func (s *patchSummary) Update() {
|
||||||
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
||||||
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
||||||
|
|
||||||
|
/* move all this to repolist and gowit repos
|
||||||
p, allp := s.GetPatches()
|
p, allp := s.GetPatches()
|
||||||
if s.allp == nil {
|
if s.allp == nil {
|
||||||
s.allp = make([]*patch, 0, 0)
|
s.allp = make([]*patch, 0, 0)
|
||||||
|
@ -228,17 +231,21 @@ func (s *patchSummary) Update() {
|
||||||
} else {
|
} else {
|
||||||
s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty")
|
s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move all this to repolist and gowit repos
|
||||||
|
|
||||||
|
/*
|
||||||
func (s *patchSummary) GetPatches() (int, []*patch) {
|
func (s *patchSummary) GetPatches() (int, []*patch) {
|
||||||
var patchcount int
|
var patchcount int
|
||||||
patches := make([]*patch, 0, 0)
|
patches := make([]*patch, 0, 0)
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
// git log --oneline devel..jcarr
|
// git log --oneline devel..jcarr
|
||||||
userv := repo.status.GetUserVersion()
|
userv := repo.GetUserVersion()
|
||||||
develv := repo.status.GetDevelVersion()
|
develv := repo.GetDevelVersion()
|
||||||
usern := repo.status.GetUserBranchName()
|
usern := repo.GetUserBranchName()
|
||||||
develn := repo.status.GetDevelBranchName()
|
develn := repo.GetDevelBranchName()
|
||||||
if userv == develv {
|
if userv == develv {
|
||||||
// log.Info("skipping unchanged repo", repo.String())
|
// log.Info("skipping unchanged repo", repo.String())
|
||||||
} else {
|
} else {
|
||||||
|
@ -293,3 +300,4 @@ func makePatchset(setdir string) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
21
tagWindow.go
21
tagWindow.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repostatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,10 +47,10 @@ func makeTagWindow() *tagWindow {
|
||||||
topGrid.NewButton("list all tags", func() {
|
topGrid.NewButton("list all tags", func() {
|
||||||
me.autotypistWindow.Disable()
|
me.autotypistWindow.Disable()
|
||||||
defer me.autotypistWindow.Enable()
|
defer me.autotypistWindow.Enable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
allTags := repo.status.Tags.ListAll()
|
allTags := repo.AllTags()
|
||||||
for _, t := range allTags {
|
for _, t := range allTags {
|
||||||
log.Info("found tag:", t.TagString(), "from", repo.status.String())
|
log.Info("found tag:", t.TagString(), "from", repo.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).SetProgName("TAGSLISTALL")
|
}).SetProgName("TAGSLISTALL")
|
||||||
|
@ -57,27 +58,27 @@ func makeTagWindow() *tagWindow {
|
||||||
topGrid.NewButton("delete all dup tags", func() {
|
topGrid.NewButton("delete all dup tags", func() {
|
||||||
me.autotypistWindow.Disable()
|
me.autotypistWindow.Disable()
|
||||||
defer me.autotypistWindow.Enable()
|
defer me.autotypistWindow.Enable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range repolist.AllRepos() {
|
||||||
if repo.String() == "go.wit.com/lib/gadgets" {
|
if repo.String() == "go.wit.com/lib/gadgets" {
|
||||||
// only do log for now
|
// only do log for now
|
||||||
} else {
|
} else {
|
||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
tagsW := repo.status.Tags
|
tagsW := repo.TagsBox()
|
||||||
tagsW.PruneSmart()
|
tagsW.PruneSmart()
|
||||||
deleteTags := tagsW.List()
|
deleteTags := tagsW.List()
|
||||||
for _, t := range deleteTags {
|
for _, t := range deleteTags {
|
||||||
tagW.grid.NewLabel(t.TagString())
|
tagW.grid.NewLabel(t.TagString())
|
||||||
tagW.grid.NewLabel(repo.status.String())
|
tagW.grid.NewLabel(repo.String())
|
||||||
tagW.grid.NewButton("delete", func() {
|
tagW.grid.NewButton("delete", func() {
|
||||||
repo.status.DeleteTag(t)
|
repo.DeleteTag(t)
|
||||||
})
|
})
|
||||||
tagW.grid.NextRow()
|
tagW.grid.NextRow()
|
||||||
if me.autoDryRun.Checked() {
|
if me.autoDryRun.Checked() {
|
||||||
log.Info("delete tag --dry-run:", t.TagString(), "from", repo.status.String())
|
log.Info("delete tag --dry-run:", t.TagString(), "from", repo.String())
|
||||||
} else {
|
} else {
|
||||||
log.Info("Deleting tag:", t.TagString(), "from", repo.status.String())
|
log.Info("Deleting tag:", t.TagString(), "from", repo.String())
|
||||||
go repo.status.DeleteTag(t)
|
go repo.DeleteTag(t)
|
||||||
log.Sleep(1)
|
log.Sleep(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue