export Status

This commit is contained in:
Jeff Carr 2024-02-17 15:47:46 -06:00
parent 15f334b2d2
commit 754371fdbf
8 changed files with 66 additions and 50 deletions

View File

@ -30,10 +30,10 @@ func docsBox(vbox *gui.Node) {
fmt.Fprintln(f, "use (") fmt.Fprintln(f, "use (")
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.Exists("go.mod") { if repo.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.String()) fmt.Fprintln(f, "\t"+repo.Status.GoPath())
} else { } else {
log.Info("missing go.mod for", repo.String()) log.Info("missing go.mod for", repo.Status.Path())
repo.MakeRedomod() repo.Status.MakeRedomod()
} }
} }
fmt.Fprintln(f, ")") fmt.Fprintln(f, ")")

View File

@ -83,7 +83,7 @@ func globalBuildOptions(vbox *gui.Node) {
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 repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
repo.CheckoutBranch(targetName) repo.Status.CheckoutBranch(targetName)
repo.Scan() repo.Scan()
} }
}) })

View File

@ -11,12 +11,12 @@ import (
func globalDisplaySetRepoState() { func globalDisplaySetRepoState() {
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.IsDirty() { if repo.Status.IsDirty() {
repo.Show() repo.Show()
continue continue
} }
if me.autoHideReadOnly.Checked() { if me.autoHideReadOnly.Checked() {
if repo.ReadOnly() { if repo.Status.ReadOnly() {
repo.Hide() repo.Hide()
continue continue
} }
@ -34,7 +34,7 @@ func globalDisplaySetRepoState() {
func globalDisplayShow() { func globalDisplayShow() {
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if me.autoHideReadOnly.Checked() { if me.autoHideReadOnly.Checked() {
if repo.ReadOnly() { if repo.Status.ReadOnly() {
continue continue
} }
} }

View File

@ -31,8 +31,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 repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.CheckDirty() { if repo.Status.CheckDirty() {
log.Warn("repo is dirty. commit your changes first", repo.String()) log.Warn("repo is dirty. commit your changes first", repo.Status.Path())
me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)") me.deleteGoSrcPkgB.SetLabel("rm ~/go/src (can't. dirty repos)")
return return
} }
@ -41,6 +41,14 @@ func globalResetOptions(box *gui.Node) {
log.Warn("no repos have uncommited changes") log.Warn("no repos have uncommited changes")
log.Warn("TODO: check things are pushed and check every dir in go/src/") log.Warn("TODO: check things are pushed and check every dir in go/src/")
me.deleteGoSrcPkgB.SetLabel("ARE YOU SURE?") me.deleteGoSrcPkgB.SetLabel("ARE YOU SURE?")
if me.deleteGoSrcPkgB.String() == "ARE YOU SURE?" {
me.deleteGoSrcPkgB.SetLabel("WE ARE NOT KIDDING?")
return
}
if me.deleteGoSrcPkgB.String() == "WE ARE NOT KIDDING" {
me.deleteGoSrcPkgB.SetLabel("ALL 90 REPOS?")
return
}
if me.deleteGoSrcPkgB.String() == "ARE YOU SURE?" { if me.deleteGoSrcPkgB.String() == "ARE YOU SURE?" {
homeDir := me.userHomePwd.String() homeDir := me.userHomePwd.String()
fullpath := filepath.Join(homeDir, "go") fullpath := filepath.Join(homeDir, "go")

View File

@ -20,7 +20,7 @@ func argGitPull() bool {
cmd := []string{"git", "pull"} cmd := []string{"git", "pull"}
var failed int = 0 var failed int = 0
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
log.Info("Running:", repo.String(), cmd) log.Info("Running:", repo.Status.Path(), cmd)
err, output := repo.RunCmd(cmd) err, output := repo.RunCmd(cmd)
if err == nil { if err == nil {
log.Info(output) log.Info(output)
@ -41,12 +41,12 @@ func argCheckoutDevel() bool {
var failed int = 0 var failed int = 0
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.CheckDirty() { if repo.CheckDirty() {
log.Info("skipping dirty repo", repo.String()) log.Info("skipping dirty repo", repo.Name())
continue continue
} }
branch := repo.GetDevelBranchName() branch := repo.Status.GetDevelBranchName()
cmd := []string{"git", "checkout", branch} cmd := []string{"git", "checkout", branch}
log.Info("Running:", cmd, "in", repo.String()) log.Info("Running:", cmd, "in", repo.Name())
err, output := repo.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)
@ -67,13 +67,13 @@ func argCheckoutUser() bool {
me.autotypistWindow.Hide() me.autotypistWindow.Hide()
var failed int = 0 var failed int = 0
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.CheckDirty() { if repo.Status.CheckDirty() {
log.Info("skipping dirty repo", repo.String()) log.Info("skipping dirty repo", repo.Name())
continue continue
} }
branch := repo.GetUserBranchName() branch := repo.Status.GetUserBranchName()
cmd := []string{"git", "checkout", branch} cmd := []string{"git", "checkout", branch}
log.Info("Running:", cmd, "in", repo.String()) log.Info("Running:", cmd, "in", repo.Name())
err, output := repo.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)

View File

@ -59,7 +59,7 @@ func makeRepoView() *repoWindow {
func (r *repoWindow) showApps() { func (r *repoWindow) showApps() {
for _, repo := range r.View.AllRepos() { for _, repo := range r.View.AllRepos() {
switch repo.RepoType() { switch repo.Status.RepoType() {
case "binary": case "binary":
//log.Info("compile here. Show()") //log.Info("compile here. Show()")
repo.Show() repo.Show()
@ -118,12 +118,12 @@ func (r *repoWindow) repoAllButtons() {
if repo.Hidden() { if repo.Hidden() {
// log.Info("skip hidden", repo.String()) // log.Info("skip hidden", repo.String())
} else { } else {
log.Info("try to build", repo.String()) log.Info("try to build", repo.Name())
if repo.Build() { if repo.Status.Build() {
log.Info("build worked", repo.String()) log.Info("build worked", repo.Name())
} else { } else {
log.Info("build failed", repo.String()) log.Info("build failed", repo.Name())
go repo.Xterm("bash") go repo.Status.Xterm("bash")
return return
} }
} }
@ -138,23 +138,23 @@ func (r *repoWindow) mergeAllDevelToMain() bool {
log.Info("merge all here") log.Info("merge all here")
for _, repo := range r.View.AllRepos() { for _, repo := range r.View.AllRepos() {
if repo.ReadOnly() { if repo.ReadOnly() {
log.Info("skipping readonly", repo.String(), repo.Status()) log.Info("skipping readonly", repo.Name(), repo.State())
continue continue
} }
if repo.Status() != "merge to main" { if repo.State() != "merge to main" {
log.Info("skipping. not merge to main", repo.String(), repo.Status()) log.Info("skipping. not merge to main", repo.Name(), repo.State())
continue continue
} }
if repo.CheckDirty() { if repo.CheckDirty() {
log.Info("skipping dirty", repo.String(), repo.Status()) log.Info("skipping dirty", repo.Name(), repo.State())
continue continue
} }
log.Info("found", repo.String(), repo.Status()) log.Info("found", repo.Name(), repo.State())
repo.NewScan() repo.NewScan()
if repo.MergeDevelToMaster() { if repo.Status.MergeDevelToMaster() {
log.Warn("THINGS SEEM OK fullAutomation() returned true.") log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else { } else {
log.Warn("last repo:", repo.Path()) log.Warn("last repo:", repo.Name())
log.Warn("THINGS FAILED fullAutomation() returned false") log.Warn("THINGS FAILED fullAutomation() returned false")
return false return false
} }
@ -168,23 +168,23 @@ func (r *repoWindow) mergeAllUserToDevel() bool {
log.Info("merge all here") log.Info("merge all here")
for _, repo := range r.View.AllRepos() { for _, repo := range r.View.AllRepos() {
if repo.ReadOnly() { if repo.ReadOnly() {
log.Info("skipping readonly", repo.String(), repo.Status()) log.Info("skipping readonly", repo.Name(), repo.State())
continue continue
} }
if repo.Status() != "merge to devel" { if repo.State() != "merge to devel" {
log.Info("skipping. not merge to devel", repo.String(), repo.Status()) log.Info("skipping. not merge to devel", repo.Name(), repo.State())
continue continue
} }
if repo.CheckDirty() { if repo.CheckDirty() {
log.Info("skipping dirty", repo.String(), repo.Status()) log.Info("skipping dirty", repo.Name(), repo.State())
continue continue
} }
log.Info("found", repo.String(), repo.Status()) log.Info("found", repo.Name(), repo.State())
repo.NewScan() repo.NewScan()
if repo.MergeUserToDevel() { if repo.Status.MergeUserToDevel() {
log.Warn("THINGS SEEM OK fullAutomation() returned true.") log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else { } else {
log.Warn("last repo:", repo.Path()) log.Warn("last repo:", repo.Status.Path())
log.Warn("THINGS FAILED fullAutomation() returned false") log.Warn("THINGS FAILED fullAutomation() returned false")
return false return false
} }

View File

@ -28,6 +28,7 @@ type patchSummary struct {
checkB *gui.Node checkB *gui.Node
totalOL *gadgets.OneLiner totalOL *gadgets.OneLiner
totalGoOL *gadgets.OneLiner
dirtyOL *gadgets.OneLiner dirtyOL *gadgets.OneLiner
readonlyOL *gadgets.OneLiner readonlyOL *gadgets.OneLiner
totalPatchesOL *gadgets.OneLiner totalPatchesOL *gadgets.OneLiner
@ -63,9 +64,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
err, output := repo.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.Name())
} else { } else {
log.Info("git fetch failed", repo.String()) log.Info("git fetch failed", repo.Name())
return return
} }
} }
@ -82,9 +83,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
err, output := repo.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.Name())
} else { } else {
log.Info("git push failed", repo.String()) log.Info("git push failed", repo.Name())
return return
} }
} }
@ -158,6 +159,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
s.totalOL = gadgets.NewOneLiner(s.grid, "Total") s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
s.grid.NextRow() s.grid.NextRow()
s.totalGoOL = gadgets.NewOneLiner(s.grid, "Total GO")
s.grid.NextRow()
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty") s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
s.grid.NextRow() s.grid.NextRow()
@ -198,22 +202,26 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
} }
func (s *patchSummary) Update() { func (s *patchSummary) Update() {
var total, dirty, readonly int var total, totalgo, dirty, readonly int
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
total += 1 total += 1
if repo.IsDirty() { if repo.Status.IsDirty() {
if repo.String() == "go.wit.com/apps/autotypist" { if repo.Status.GoPath() == "go.wit.com/apps/autotypist" {
// log.Info("ignoring dirty autotypist for now") // log.Info("ignoring dirty autotypist for now")
dirty += 1 dirty += 1
} else { } else {
dirty += 1 dirty += 1
} }
} }
if repo.ReadOnly() { if repo.Status.ReadOnly() {
readonly += 1 readonly += 1
} }
if repo.Status.IsGoLang() {
totalgo += 1
}
} }
s.totalOL.SetText(strconv.Itoa(total) + " repos") s.totalOL.SetText(strconv.Itoa(total) + " repos")
s.totalGoOL.SetText(strconv.Itoa(totalgo) + " repos")
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")

View File

@ -50,7 +50,7 @@ func makeTagWindow() *tagWindow {
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
allTags := repo.AllTags() allTags := repo.AllTags()
for _, t := range allTags { for _, t := range allTags {
log.Info("found tag:", t.TagString(), "from", repo.String()) log.Info("found tag:", t.TagString(), "from", repo.Name())
} }
} }
}).SetProgName("TAGSLISTALL") }).SetProgName("TAGSLISTALL")
@ -59,7 +59,7 @@ func makeTagWindow() *tagWindow {
me.autotypistWindow.Disable() me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable() defer me.autotypistWindow.Enable()
for _, repo := range repolist.AllRepos() { for _, repo := range repolist.AllRepos() {
if repo.String() == "go.wit.com/lib/gadgets" { if repo.GoPath() == "go.wit.com/lib/gadgets" {
// only do log for now // only do log for now
} else { } else {
// continue // continue
@ -69,15 +69,15 @@ func makeTagWindow() *tagWindow {
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.String()) tagW.grid.NewLabel(repo.Name())
tagW.grid.NewButton("delete", func() { tagW.grid.NewButton("delete", func() {
repo.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.String()) log.Info("delete tag --dry-run:", t.TagString(), "from", repo.Name())
} else { } else {
log.Info("Deleting tag:", t.TagString(), "from", repo.String()) log.Info("Deleting tag:", t.TagString(), "from", repo.Name())
go repo.DeleteTag(t) go repo.DeleteTag(t)
log.Sleep(1) log.Sleep(1)
} }