rewriting logic to repolist
This commit is contained in:
parent
28f5e15350
commit
a5cd066cd2
|
@ -42,7 +42,7 @@ func CheckReady() bool {
|
|||
if goSumS == "RELEASED" {
|
||||
return true
|
||||
}
|
||||
if goSumS == "PRIMATIVE" {
|
||||
if release.current.Status.IsPrimitive() {
|
||||
if targetS == lastS {
|
||||
release.current.SetGoState("RELEASED")
|
||||
}
|
||||
|
|
68
doRelease.go
68
doRelease.go
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -23,36 +24,6 @@ func doRelease() bool {
|
|||
log.Warn("version does not start with v.", release.version.String())
|
||||
return false
|
||||
}
|
||||
switch release.current.GoState() {
|
||||
case "PRIMATIVE":
|
||||
log.Warn("can do PRIMATIVE", release.current.Name())
|
||||
case "GOOD":
|
||||
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
|
||||
case "manually chosen":
|
||||
log.Warn("attempting manual release", release.version.String())
|
||||
/*
|
||||
case "NOT READY":
|
||||
log.Warn("attempting to release. TODO: recheck go.sum here", release.version.String())
|
||||
log.Warn("Sleep 10")
|
||||
log.Sleep(10)
|
||||
case "UNRELEASED":
|
||||
log.Warn("attempting to release. TODO: dig deep on go.sum here", release.version.String())
|
||||
log.Warn("Sleep 10")
|
||||
log.Sleep(10)
|
||||
*/
|
||||
default:
|
||||
log.Warn("what is this?", release.version.String(), release.current.Name())
|
||||
return false
|
||||
}
|
||||
|
||||
if release.current.Status.ReadOnly() {
|
||||
log.Info("sorry, it's read-only")
|
||||
return true
|
||||
}
|
||||
if release.current.Status.CheckDirty() {
|
||||
log.Info("sorry, it's still dirty")
|
||||
return false
|
||||
}
|
||||
|
||||
curName := release.current.Status.GetCurrentBranchName()
|
||||
mName := release.current.Status.GetMasterBranchName()
|
||||
|
@ -61,11 +32,15 @@ func doRelease() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if !checkValidGoSum(release.current) {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Info("\ttag and push", curName, release.version.String(), me.releaseReasonS)
|
||||
|
||||
var all [][]string
|
||||
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
||||
if release.current.Status.CheckPrimativeGoMod() {
|
||||
if release.current.Status.IsPrimitive() {
|
||||
// don't add go.sum here. TODO: check for go.sum file and fail
|
||||
} else {
|
||||
all = append(all, []string{"git", "add", "-f", "go.sum"})
|
||||
|
@ -122,6 +97,23 @@ func doRelease() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func checkValidGoSum(repo *repolist.Repo) bool {
|
||||
ok, err := me.repos.View.CheckValidGoSum(repo)
|
||||
if err != nil {
|
||||
log.Info("go mod tidy not ok")
|
||||
return false
|
||||
}
|
||||
if ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// release.current.setGoSumStatus("CLEAN")
|
||||
release.status.SetValue("GOOD")
|
||||
release.notes.SetValue("CheckValidGoSum() does not seem to lie")
|
||||
return true
|
||||
}
|
||||
release.notes.SetValue("CheckValidGoSum() failed")
|
||||
return false
|
||||
}
|
||||
|
||||
// try to figure out if there is another package to update
|
||||
func doReleaseFindNext() bool {
|
||||
// scan for new repo
|
||||
|
@ -131,21 +123,9 @@ func doReleaseFindNext() bool {
|
|||
log.Info("findNextDirty() could not find anything")
|
||||
return false
|
||||
}
|
||||
release.current.Status.CheckSafeGoSumRemake()
|
||||
if release.current.Status.MakeRedomod() {
|
||||
log.Info("Redo mod ok")
|
||||
} else {
|
||||
log.Info("go mod tidy not ok")
|
||||
return false
|
||||
}
|
||||
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// release.current.setGoSumStatus("CLEAN")
|
||||
release.status.SetValue("GOOD")
|
||||
release.notes.SetValue("CheckGoSum() does not seem to lie")
|
||||
if checkValidGoSum(release.current) {
|
||||
return true
|
||||
}
|
||||
release.notes.SetValue("CheckGoSum() failed")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/gui"
|
||||
|
@ -46,20 +45,20 @@ func showHideRepos(repo *repolist.Repo) {
|
|||
repo.Show()
|
||||
}
|
||||
|
||||
func globalDisplayShow() {
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if repo.Status.ReadOnly() {
|
||||
continue
|
||||
}
|
||||
func globalDisplayShow(repo *repolist.Repo) {
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if repo.Status.ReadOnly() {
|
||||
repo.Hide()
|
||||
return
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if repo.State() == "PERFECT" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
repo.Show()
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if repo.State() == "PERFECT" {
|
||||
repo.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
repo.Show()
|
||||
}
|
||||
|
||||
func globalDisplayOptions(box *gui.Node) {
|
||||
|
@ -76,24 +75,13 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
me.repos.Hide()
|
||||
}
|
||||
log.Info("showing reposwin")
|
||||
// showHideRepos()
|
||||
|
||||
// have to run this twice for now
|
||||
// scanForReady()
|
||||
// scanForReady()
|
||||
// findNextDirty("")
|
||||
// double check the found next repo
|
||||
// fullDoubleCheckFix()
|
||||
})
|
||||
hidegrid.NextRow()
|
||||
|
||||
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
|
||||
me.autoHideReadOnly.Custom = func() {
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
// showHideRepos()
|
||||
} else {
|
||||
globalDisplayShow()
|
||||
}
|
||||
log.Info("registered hide function to globalDisplayShow()")
|
||||
me.repos.View.RegisterHideFunction(globalDisplayShow)
|
||||
}
|
||||
hidegrid.NextRow()
|
||||
|
||||
|
@ -101,13 +89,6 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
me.autoHidePerfect.Custom = func() {
|
||||
log.Info("registered hide function to showHideRepos()")
|
||||
me.repos.View.RegisterHideFunction(showHideRepos)
|
||||
/*
|
||||
if me.autoHidePerfect.Checked() {
|
||||
showHideRepos()
|
||||
} else {
|
||||
globalDisplayShow()
|
||||
}
|
||||
*/
|
||||
}
|
||||
hidegrid.NextRow()
|
||||
|
||||
|
@ -155,8 +136,6 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
scanForReady()
|
||||
|
||||
findNextDirty("")
|
||||
// double check the found next repo
|
||||
fullDoubleCheckFix()
|
||||
})
|
||||
|
||||
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
|
||||
|
@ -183,23 +162,20 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
})
|
||||
|
||||
var longB *gui.Node
|
||||
longB = grid.NewButton("redo go.sum", func() {
|
||||
os.Unsetenv("GO111MODULE")
|
||||
longB = grid.NewButton("redo all go.sum", func() {
|
||||
longB.Disable()
|
||||
me.Disable()
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
if whitelist(repo.GoPath()) {
|
||||
continue
|
||||
}
|
||||
if repo.Status.ReadOnly() {
|
||||
continue
|
||||
}
|
||||
if repo.Status.MakeRedomod() {
|
||||
log.Info("redo go.sum failed on", repo.Name())
|
||||
// me.Enable()
|
||||
// longB.Enable()
|
||||
// longB.SetLabel("FAILED")
|
||||
// return
|
||||
ok, err := repo.Status.MakeRedomod()
|
||||
if !ok {
|
||||
log.Info("redo go.sum failed on", repo.GoPath(), err)
|
||||
me.Enable()
|
||||
longB.Enable()
|
||||
longB.SetLabel("FAILED")
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Info("redo go.sum finished ok!")
|
||||
|
|
10
main.go
10
main.go
|
@ -32,6 +32,11 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
// unset the go development ENV var to generate release files
|
||||
// this is required for go mod init & tidy. Also, if the
|
||||
// user drops to a shell or xterm, then they shouldn't be set there either
|
||||
os.Unsetenv("GO111MODULE")
|
||||
|
||||
me.myGui = gui.New()
|
||||
me.myGui.InitEmbed(resToolkit)
|
||||
me.myGui.Default()
|
||||
|
@ -72,6 +77,9 @@ func main() {
|
|||
// hopefully this is the list of all the golang packages and only the GUI golang packages
|
||||
me.repos = makeRepoView()
|
||||
|
||||
// register a Show/Hide function for the repo list table
|
||||
me.repos.View.RegisterHideFunction(showHideRepos)
|
||||
|
||||
// create the right side of the main window
|
||||
createReleaseBox(me.mainBox)
|
||||
|
||||
|
@ -88,7 +96,7 @@ func main() {
|
|||
|
||||
// reads in the State of all the repos
|
||||
// TODO: should not really be necessary directly after init()
|
||||
me.repos.View.ScanRepositories()
|
||||
// me.repos.View.ScanRepositories()
|
||||
|
||||
me.Enable()
|
||||
|
||||
|
|
162
releaseBox.go
162
releaseBox.go
|
@ -163,44 +163,9 @@ func createReleaseBox(box *gui.Node) {
|
|||
release.whitelist[release.current.GoPath()] = release.current
|
||||
})
|
||||
|
||||
release.checkSafeB = release.grid.NewButton("fullDoubleCheckFix()", func() {
|
||||
release.checkGoSumB = release.grid.NewButton("checkValidGoSum()", func() {
|
||||
buttonDisable()
|
||||
if fullDoubleCheckFix() {
|
||||
log.Info("go.sum is clean")
|
||||
} else {
|
||||
log.Info("repo go.sum FAILED")
|
||||
return
|
||||
}
|
||||
buttonEnable()
|
||||
})
|
||||
|
||||
release.checkGoSumB = release.grid.NewButton("CheckGoSum()", func() {
|
||||
buttonDisable()
|
||||
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// release.current.setGoSumStatus("CLEAN")
|
||||
release.status.SetText("GOOD")
|
||||
release.notes.SetText("CheckGoSum() does not seem to lie")
|
||||
}
|
||||
buttonEnable()
|
||||
})
|
||||
|
||||
release.makeRedomodB = release.grid.NewButton("make redomod", func() {
|
||||
buttonDisable()
|
||||
if release.current.Status.MakeRedomod() {
|
||||
} else {
|
||||
log.Info("This is bad. stop here")
|
||||
}
|
||||
buttonEnable()
|
||||
})
|
||||
|
||||
release.grid.NewButton("goodCheckGoSum()", func() {
|
||||
buttonDisable()
|
||||
if goodCheckGoSum() {
|
||||
log.Info("goodCheckGoSum() GOOD")
|
||||
} else {
|
||||
log.Info("goodCheckGoSum() FAILED")
|
||||
}
|
||||
checkValidGoSum(release.current)
|
||||
buttonEnable()
|
||||
})
|
||||
release.grid.NextRow()
|
||||
|
@ -234,77 +199,6 @@ func createReleaseBox(box *gui.Node) {
|
|||
release.grid.NextRow()
|
||||
}
|
||||
|
||||
func fullDoubleCheckFix() bool {
|
||||
release.current.Status.CheckSafeGoSumRemake()
|
||||
if !release.current.Status.MakeRedomod() {
|
||||
log.Info("go mod failed")
|
||||
return false
|
||||
}
|
||||
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||
log.Info("go.sum is clean")
|
||||
} else {
|
||||
log.Info("repo go.sum FAILED")
|
||||
return false
|
||||
}
|
||||
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// release.current.setGoSumStatus("CLEAN")
|
||||
release.status.SetValue("GOOD")
|
||||
release.notes.SetValue("CheckGoSum() does not seem to lie")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func goodCheckGoSum() bool {
|
||||
tmp := release.current.Name()
|
||||
log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.GoState())
|
||||
|
||||
var maybe bool = true
|
||||
goConfig := release.current.Status.GetGoDeps()
|
||||
for depname, version := range goConfig {
|
||||
log.Info("Starting repo deps:", depname, version)
|
||||
repo := me.repos.View.FindRepo(depname)
|
||||
if repo == nil {
|
||||
log.Info(" skipping repo == nil", depname, version)
|
||||
continue
|
||||
}
|
||||
goSumS := repo.GoState()
|
||||
// ignore dependencies on whitelisted repos
|
||||
// TODO: warn the user about the whitelist
|
||||
if goSumS == "WHITELIST" {
|
||||
log.Info(" skipping repo == nil", depname, version)
|
||||
continue
|
||||
}
|
||||
// check if the dependent repo is ReadOnly
|
||||
// if so, there isn't anything we can do about
|
||||
// version mis-matches
|
||||
if repo.ReadOnly() {
|
||||
log.Info(" repo deps: WHITELIST", depname, version)
|
||||
continue
|
||||
}
|
||||
log.Info("Checking repo deps match:", depname, version)
|
||||
lastS := repo.LastTag()
|
||||
targetS := repo.Status.GetTargetVersion()
|
||||
log.Info(" repo deps:", depname, version, "vs", goSumS, lastS, targetS)
|
||||
if lastS != targetS {
|
||||
log.Info("repo deps: FALSE lastS != targetS", lastS, targetS)
|
||||
log.Info("repo deps: FALSE status.ReadOnly()", release.current.ReadOnly())
|
||||
log.Info("repo deps: FALSE path", release.current.GoPath())
|
||||
maybe = false
|
||||
}
|
||||
}
|
||||
if maybe {
|
||||
log.Info("SUCCEEDED.", release.current.Name())
|
||||
log.Info("SUCCEEDED. goSumStatus.String() =", release.current.GoState())
|
||||
log.Info("SUCCEEDED. MAYBE. try it again get go.sum requirements")
|
||||
return true
|
||||
} else {
|
||||
log.Info("FAILED. move on")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func buttonDisable() {
|
||||
me.Disable()
|
||||
}
|
||||
|
@ -352,45 +246,37 @@ func scanForReady() bool {
|
|||
|
||||
// trys to figure out if there is still something to update
|
||||
// todo: redo this logic as it is terrible
|
||||
// rename this findNext()
|
||||
func findNextDirty(onlyKind string) bool {
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
goSumS := repo.GoState()
|
||||
// dirtyS := repo.State()
|
||||
|
||||
log.Info("findNextDirty()", repo.GoPath(), goSumS)
|
||||
if repo.ReadOnly() {
|
||||
log.Info("findNextDirty() skipping readonly")
|
||||
continue
|
||||
}
|
||||
if goSumS == "PRIMATIVE" {
|
||||
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
||||
if release.version.String() == release.current.Status.GetLastTagVersion() {
|
||||
// everything is fine. the primative has already been released
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
continue
|
||||
} else {
|
||||
if onlyKind == "PRIMATIVE" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if goSumS == "IGNORE" {
|
||||
continue
|
||||
}
|
||||
if goSumS == "RELEASED" {
|
||||
if repo.Status.GetTargetVersion() == repo.Status.GetCurrentVersion() {
|
||||
continue
|
||||
}
|
||||
if goSumS == "WHITELIST" {
|
||||
continue
|
||||
}
|
||||
setCurrentRepo(repo, "REDO GOSUM", "try redoing the gosum")
|
||||
newgoSumS := release.current.GoState()
|
||||
// newdirtyS := release.current.dirtyLabel.String()
|
||||
newlastS := release.current.LastTag()
|
||||
if goodCheckGoSum() {
|
||||
log.Info("findNextDirty() returning true from goodCheckGoSum()", newgoSumS, newgoSumS, newlastS)
|
||||
if goSumS == "IGNORE" {
|
||||
continue
|
||||
}
|
||||
if repo.ReadOnly() {
|
||||
log.Info("findNextDirty() skipping readonly")
|
||||
continue
|
||||
}
|
||||
if repo.CheckDirty() {
|
||||
log.Info("findNextDirty() skipping readonly")
|
||||
continue
|
||||
}
|
||||
log.Info("findNextDirty()", repo.GoPath(), goSumS)
|
||||
if repo.Status.IsPrimitive() {
|
||||
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
||||
return true
|
||||
}
|
||||
continue
|
||||
}
|
||||
if checkValidGoSum(release.current) {
|
||||
setCurrentRepo(repo, "should be good to release", "pretty sure")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
32
scanGoSum.go
32
scanGoSum.go
|
@ -2,21 +2,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func checkSafeGoSumRemake(r *repolist.Repo) {
|
||||
if ok, bad := r.Status.CheckSafeGoSumRemake(); ok {
|
||||
log.Info("checkSafeGoSumRemake() is safe to redo")
|
||||
r.SetGoState("SAFE")
|
||||
r.Status.MakeRedomod()
|
||||
} else {
|
||||
log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
|
||||
r.SetGoState("BAD DEP")
|
||||
}
|
||||
}
|
||||
|
||||
func scanGoSum() {
|
||||
for _, repo := range me.repos.View.AllRepos() {
|
||||
if repo.GoPath() == "go.wit.com/apps/guireleaser" {
|
||||
|
@ -31,9 +19,9 @@ func scanGoSum() {
|
|||
if repo.GoState() == "DIRTY" {
|
||||
continue
|
||||
}
|
||||
if repo.Status.CheckPrimativeGoMod() {
|
||||
log.Info("PRIMATIVE repo:", latestversion, repo.GoPath())
|
||||
repo.SetGoState("PRIMATIVE")
|
||||
if repo.Status.IsPrimitive() {
|
||||
log.Info("PRIMITIVE repo:", latestversion, repo.GoPath())
|
||||
repo.SetGoState("PRIMITIVE")
|
||||
continue
|
||||
}
|
||||
if repo.CheckDirty() {
|
||||
|
@ -48,20 +36,6 @@ func scanGoSum() {
|
|||
// release.openrepo.Enable()
|
||||
continue
|
||||
}
|
||||
if ok, missing := repo.Status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
repo.SetGoState("CLEAN")
|
||||
} else {
|
||||
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
|
||||
repo.SetGoState("BAD")
|
||||
|
||||
// release.repo.SetValue(repo.status.String())
|
||||
// release.status.SetValue("bad")
|
||||
// release.notes.SetValue("the go.sum file is wrong")
|
||||
// release.current = repo
|
||||
// release.openrepo.Enable()
|
||||
continue
|
||||
}
|
||||
status := repo.State()
|
||||
if status == "PERFECT" {
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue