remove lots of old junk code

This commit is contained in:
Jeff Carr 2024-02-29 21:57:13 -06:00
parent 5aa110ae8b
commit d60a565d88
5 changed files with 13 additions and 239 deletions

View File

@ -1,126 +0,0 @@
package main
import (
"os"
"path/filepath"
"go.wit.com/log"
)
func CheckReady() bool {
if me.current == nil {
log.Info("find the next repo first")
return false
}
goSumS := me.current.GoState()
dirtyS := me.current.State()
lastS := me.current.Status.GetLastTagVersion()
currentS := me.current.Status.GetCurrentBranchVersion()
var targetS string
targetS = me.release.version.String()
log.Info("repo:", me.current.State(), goSumS, dirtyS, lastS, currentS, targetS)
if goSumS == "RELEASED" {
return true
}
if me.current.Status.IsPrimitive() {
if targetS == lastS {
me.current.SetGoState("RELEASED")
}
return true
}
if goSumS == "UNRELEASED" {
return true
}
if goSumS == "READY" {
if targetS == lastS {
me.current.SetGoState("RELEASED")
return true
}
if lastS == currentS {
me.current.SetGoState("UNRELEASED")
}
return true
}
me.current.SetGoState("NOT READY")
if me.current.Status.ReadOnly() {
log.Info("\trepo is read only")
return false
}
if targetS == lastS {
log.Info("\trepo is already done", lastS, "=", targetS)
me.current.SetGoState("READY")
return true
}
if lastS == currentS {
log.Info("\trepo is already done", lastS, "=", targetS)
me.current.SetGoState("READY")
return true
}
if goSumS == "BAD" {
log.Info("\trepo is ready", me.current.State(), "BAD == BAD")
} else {
log.Info("\trepo is ready maybe", me.current.State(), "BAD !=", goSumS)
}
if me.current.Status.CheckDirty() {
log.Info("\trepo is dirty")
return false
} else {
log.Info("\trepo is ready", me.current.State(), "not dirty")
}
fullpath := filepath.Join(me.goSrcPwd.String(), me.current.State())
testf := filepath.Join(fullpath, "go.mod")
if Exists(testf) {
log.Info("\trepo is not ready. go.mod exists")
return false
}
testf = filepath.Join(fullpath, "go.sum")
if Exists(testf) {
log.Info("\trepo is not ready. go.sum exists")
return false
}
testf = filepath.Join(fullpath, "LICENSE")
if !Exists(testf) {
log.Info("\trepo is not ready. missing LICENSE")
return false
}
// final checks here
if dirtyS == "unchanged" {
log.Info("\trepo is ready", me.current.Name(), "unchanged")
} else {
log.Info("\trepo is not ready", dirtyS, "!= 'unchanged'")
return false
}
curName := me.current.Status.GetCurrentBranchName()
mName := me.current.Status.GetMasterBranchName()
if curName == mName {
log.Info("\trepo is ready working from main branch", curName, "=", mName)
} else {
log.Info("\trepo is not ready main branch", curName, "!=", mName)
return false
}
me.current.SetGoState("READY")
return true
}
// returns true if the file exists
func Exists(file string) bool {
_, err := os.Stat(file)
if err != nil {
return false
}
return true
}

View File

@ -63,7 +63,7 @@ func doRelease() bool {
}
log.Info("PUBLISH OK")
me.current.SetGoState("RELEASED")
// me.current.SetGoState("RELEASED")
// unwind and re-tag. Now that the go.mod and go.sum are published, revert
// to the development branch
@ -167,7 +167,7 @@ func doPublishVersion() bool {
if err == nil {
log.Info("SELF UPDATE OK. out =", out)
log.Info("SELF UPDATE WORKED")
me.current.SetGoState("RELEASED")
// me.current.SetGoState("RELEASED")
return true
}
return false

View File

@ -21,10 +21,10 @@ func hideFunction(r *repolist.RepoRow) {
}
// always show repos that have not been merged ?
if r.GoState() == "merge to devel" {
r.Show()
return
}
// if r.GoState() == "merge to devel" {
// r.Show()
// return
// }
// hide read-only repos
if os.Getenv("AUTOTYPIST_READONLY") == "hide" {

View File

@ -1,58 +0,0 @@
// This is a simple example
package main
import (
"path/filepath"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func lookToUnwind(r *repolist.RepoRow) bool {
goSumS := r.GoState()
dirtyS := r.State()
currentS := r.Status.GetCurrentBranchVersion()
log.Info("repo:", r.Name(), goSumS, dirtyS, r.State(), currentS)
curName := r.Status.GetCurrentBranchName()
mName := r.Status.GetMasterBranchName()
if curName == mName {
log.Info("\trepo is ready working from main branch", curName, "=", mName)
} else {
log.Info("\trepo is not ready main branch", curName, "!=", mName)
r.SetGoState("CAN NOT UNWIND")
return false
}
if r.LastTag() != currentS {
log.Info("\trepo version mismatch last vs current", r.LastTag(), "!=", currentS)
r.SetGoState("CAN NOT UNWIND")
return false
}
if me.release.version.String() != r.LastTag() {
log.Info("\trepo version mismatch last vs official", r.LastTag(), "!=", me.release.version.String())
r.SetGoState("CAN NOT UNWIND")
return false
}
fullpath := filepath.Join(me.goSrcPwd.String(), r.GoPath())
testf := filepath.Join(fullpath, "go.mod")
if Exists(testf) {
log.Info("\trepo is ready. go.mod exists")
r.SetGoState("UNWIND")
return true
}
fullpath = filepath.Join(me.GoSrcPath(), r.GoPath())
testf = filepath.Join(fullpath, "go.sum")
if Exists(testf) {
log.Info("\trepo is ready. go.sum exists")
r.SetGoState("UNWIND")
return true
}
r.SetGoState("NO UNWIND?")
return false
}

View File

@ -12,11 +12,10 @@ import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/shell"
)
type releaseStruct struct {
// current *repolist.Repo
box *gui.Node
group *gui.Node
grid *gui.Node
@ -25,12 +24,8 @@ type releaseStruct struct {
readOnly *gadgets.OneLiner
notes *gadgets.OneLiner
version *gadgets.OneLiner
// versionS string
// widgetVersionS string
releaseVersionB *gui.Node
// unreleaseB *gui.Node
reason *gadgets.BasicEntry
// reasonS string
openrepo *gui.Node
@ -58,7 +53,6 @@ func (w *autoType) Enable() {
func createReleaseBox(box *gui.Node) {
initWhitelist()
// me.release.box = box
me.release.box = box.NewVerticalBox("vbox")
me.release.group = me.release.box.NewGroup("Current Repo")
me.release.grid = me.release.group.NewGrid("buildOptions", 0, 0)
@ -120,7 +114,7 @@ func createReleaseBox(box *gui.Node) {
me.goSrcPwd.SetText(srcDir)
testf := filepath.Join(srcDir, "go.wit.com/apps/guireleaser", "go.sum")
if !Exists(testf) {
if !shell.Exists(testf) {
log.Info("go.sum missing", testf)
panic("redo go.sum")
}
@ -129,9 +123,9 @@ func createReleaseBox(box *gui.Node) {
grid := group.NewGrid("buildOptions", 0, 0)
grid.NewButton("set to IGNORE", func() {
tmp := me.current.GoState()
log.Info("trying to set repo IGNORE is now =", tmp)
me.current.SetGoState("IGNORE")
// tmp := me.current.GoState()
log.Info("trying to whitelist repo", me.current.GoPath())
// me.current.SetGoState("IGNORE")
me.release.whitelist[me.current.GoPath()] = me.current
})
@ -141,16 +135,6 @@ func createReleaseBox(box *gui.Node) {
buttonEnable()
})
grid.NewButton("Check Ready", func() {
buttonDisable()
defer buttonEnable()
if CheckReady() {
log.Info("repo is ready", me.current.Name())
return
} else {
log.Info("\trepo is not ready", me.current.Name())
}
})
grid.NextRow()
group = me.release.box.NewGroup("Process against all repos")
@ -277,46 +261,20 @@ func setCurrentRepo(newcur *repolist.RepoRow, s string, note string) bool {
me.current = newcur
me.release.version.SetText(me.current.Status.GetTargetVersion())
me.release.releaseVersionB.SetText("release version " + me.current.Status.GetTargetVersion())
// me.release.unreleaseB.SetText("un-release version " + me.current.targetVersion.String())
me.release.openrepo.Enable()
return true
}
func scanForReady() bool {
for _, repo := range me.repos.View.AllRepos() {
goSumS := repo.GoState()
dirtyS := repo.State()
log.Info("findNext()", repo.GoPath(), goSumS, dirtyS)
if whitelist(repo.GoPath()) {
log.Info("found WHITELIST", repo.GoPath())
repo.SetGoState("WHITELIST")
continue
}
log.Info("scan for Ready: found a repo")
if setCurrentRepo(repo, "checking ready", "notsure") {
CheckReady()
}
}
return true
}
// trys to figure out if there is still something to update
// todo: redo this logic as it is terrible
// rename this findNext()
func findNext() bool {
for _, repo := range me.repos.View.AllRepos() {
goSumS := repo.GoState()
if repo.Status.IsReleased() {
continue
}
if goSumS == "WHITELIST" {
continue
}
if goSumS == "IGNORE" {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
@ -331,7 +289,7 @@ func findNext() bool {
// if ! repo.Status.Exists("go.sum") {
// }
if repo.Status.IsPrimitive() {
log.Info("findNext()", repo.GoPath(), goSumS)
log.Info("findNext()", repo.GoPath())
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
return true
}