From 0fa1ea471fbc196b5f0af10f0a50ab93c35f92f9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 3 Dec 2024 13:23:55 -0600 Subject: smarter IsReadOnly() logic --- findNext.go | 4 +- human.go | 21 +++----- main.go | 2 +- makePrepareRelease.go | 129 -------------------------------------------------- prepareRelease.go | 128 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 146 deletions(-) delete mode 100644 makePrepareRelease.go create mode 100644 prepareRelease.go diff --git a/findNext.go b/findNext.go index c347f3c..c0d16c9 100644 --- a/findNext.go +++ b/findNext.go @@ -107,7 +107,7 @@ func goodGodeps(repo *repolist.RepoRow) bool { for deps.Scan() { depRepo := deps.Next() // log.Info("found dep", depRepo.GetGoPath()) - if me.forge.IsReadOnly(depRepo.GetGoPath()) { + if me.forge.Config.IsReadOnly(depRepo.GoPath) { // log.Info("IsReadOnly = true", depRepo.GetGoPath()) continue } else { @@ -156,7 +156,7 @@ func fixGodeps(check *gitpb.Repo) bool { for deps.Scan() { depRepo := deps.Next() // log.Info("found dep", depRepo.GetGoPath()) - if me.forge.IsReadOnly(depRepo.GetGoPath()) { + if me.forge.Config.IsReadOnly(depRepo.GoPath) { log.Info("IsReadOnly = true", depRepo.GetGoPath()) continue } else { diff --git a/human.go b/human.go index c204aed..fab7e94 100644 --- a/human.go +++ b/human.go @@ -25,7 +25,7 @@ func PrintReport(readonly string, onlydirty string, perfect string) { continue } - if repo.ReadOnly() { + if me.forge.Config.IsReadOnly(repo.GoPath()) { if readonly == "true" { log.Info(header + "readonly") } @@ -60,28 +60,21 @@ func PrintReleaseReport(readonly string, perfect string) { log.Info(repolist.ReleaseReportHeader()) - loop := me.repos.View.ReposSortByName() + loop := me.forge.Repos.SortByGoPath() for loop.Scan() { - repo := loop.Repo() - - if repo.ReadOnly() && (readonly == "true") { + check := loop.Next() + if me.forge.IsReadOnly(check) { continue } - if (repo.State() == "PERFECT") && (perfect == "true") { - continue - } - if repo.Status.IsReleased() { + if check.GetCurrentBranchVersion() == check.GetTargetVersion() { continue } count += 1 - header := repo.StandardReleaseHeader() - log.Info(header) - check := me.forge.Repos.FindByGoPath(repo.GoPath()) if check == nil { - log.Info("boo, you didn't git clone", repo.GoPath()) + log.Info("boo, you didn't git clone", check.GoPath) continue } - log.Info(me.forge.StandardReleaseHeader(check, repo.State())) + log.Info(me.forge.StandardReleaseHeader(check, "")) } log.Info(fmt.Sprintf("total repo count = %d", count)) } diff --git a/main.go b/main.go index cdc2a6d..c14aebd 100644 --- a/main.go +++ b/main.go @@ -110,7 +110,7 @@ func main() { loop := me.repos.View.ReposSortByName() for loop.Scan() { repo := loop.Repo() - if me.forge.IsReadOnly(repo.GoPath()) { + if me.forge.Config.IsReadOnly(repo.GoPath()) { repo.Status.SetReadOnly(true) } else { repo.Status.SetReadOnly(false) diff --git a/makePrepareRelease.go b/makePrepareRelease.go deleted file mode 100644 index a599210..0000000 --- a/makePrepareRelease.go +++ /dev/null @@ -1,129 +0,0 @@ -package main - -import ( - "os" - - "go.wit.com/log" -) - -func makePrepareRelease() { - me.Disable() - me.release.box.Disable() - defer me.Enable() - - if setAllBranchesToMaster() { - // if it succeeds, disable this button - me.setBranchesToMasterB.Disable() - me.release.box.Enable() - PrintReleaseReport("", "") - } else { - log.Info("setAllBranchesToMaster() failed") - } - - // first reset all the target versions back to the current version - // incase there was a partial release process running that - // did not finish - loop := me.repos.View.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - - // find the gitpb.Repo - check := me.forge.Repos.FindByGoPath(repo.GoPath()) - if check == nil { - log.Info("boo, you didn't git clone", repo.GoPath()) - os.Exit(-1) - } - - // set the target version to the current master version - curver := repo.Status.GetMasterVersion() - check.SetTargetVersion(curver) - } - - // on startup, run fixGoDeps() on every go.sum that didn't match - if argv.Fix { - loop = me.repos.View.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - // find the gitpb.Repo - check := me.forge.Repos.FindByGoPath(repo.GoPath()) - if check == nil { - log.Info("boo, you didn't git clone", repo.GoPath()) - os.Exit(-1) - } - if !me.forge.FinalGoDepsCheckOk(check) { - fixGodeps(check) - } - } - } - - // now figure out what to release and increment the version - loop = me.repos.View.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - // find the gitpb.Repo - check := me.forge.Repos.FindByGoPath(repo.GoPath()) - if check == nil { - log.Info("boo, you didn't git clone", repo.GoPath()) - os.Exit(-1) - } - - // if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" { - if check.GetGoPath() == "go.wit.com/gui" { - log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive) - if me.forge.FinalGoDepsCheckOk(check) { - log.Info("arg final check true", check.GetGoPath()) - } else { - log.Info("arg final check false", check.GetGoPath()) - // os.Exit(-1) - } - // see if there is a new version - master := repo.Status.GetMasterVersion() - lastTag := repo.Status.LastTag() - log.Info("arg ", master, lastTag) - // os.Exit(-1) - } - // check if the package dependancies changed, if so, re-publish - if !check.GoPrimitive { - if me.forge.FinalGoDepsCheckOk(check) { - log.Printf("go.sum is perfect! %s\n", check.GetGoPath()) - } else { - log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath()) - repo.Status.IncrementRevisionVersion("godeps changed") - target := repo.Status.GetTargetVersion() - check.SetTargetVersion(target) - continue - } - } - - // see if there is a new version - master := repo.Status.GetMasterVersion() - lastTag := repo.Status.LastTag() - if master == lastTag { - repo.Status.SetTargetVersion(master) - } else { - repo.Status.IncrementRevisionVersion("Nov 2024 test") - target := repo.Status.GetTargetVersion() - check.SetTargetVersion(target) - } - // if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" { - // if check.GetGoPath() == "go.wit.com/gui" { - if check.GetGoPath() == "go.wit.com/dev/davecgh/spew" { - log.Info(repo.StandardReleaseHeader()) - log.Info(me.forge.StandardReleaseHeader(check, repo.State())) - log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive) - if me.forge.FinalGoDepsCheckOk(check) { - log.Info("go.sum is perfect") - } else { - log.Info("go.sum check false") - } - // see if there is a new version - master := repo.Status.GetMasterVersion() - lastTag := repo.Status.LastTag() - log.Info("arg ", master, lastTag) - if master != lastTag { - os.Exit(-1) - } - } - } - findNext() -} diff --git a/prepareRelease.go b/prepareRelease.go new file mode 100644 index 0000000..bd8d433 --- /dev/null +++ b/prepareRelease.go @@ -0,0 +1,128 @@ +package main + +import ( + "os" + + "go.wit.com/log" +) + +func makePrepareRelease() { + me.Disable() + me.release.box.Disable() + defer me.Enable() + + if setAllBranchesToMaster() { + // if it succeeds, disable this button + me.setBranchesToMasterB.Disable() + me.release.box.Enable() + PrintReleaseReport("", "") + } else { + log.Info("setAllBranchesToMaster() failed") + } + + // first reset all the target versions back to the current version + // incase there was a partial release process running that + // did not finish + loop := me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + + // find the gitpb.Repo + check := me.forge.Repos.FindByGoPath(repo.GoPath()) + if check == nil { + log.Info("boo, you didn't git clone", repo.GoPath()) + os.Exit(-1) + } + + // set the target version to the current master version + curver := repo.Status.GetMasterVersion() + check.SetTargetVersion(curver) + } + + // on startup, run fixGoDeps() on every go.sum that didn't match + if argv.Fix { + loop = me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + // find the gitpb.Repo + check := me.forge.Repos.FindByGoPath(repo.GoPath()) + if check == nil { + log.Info("boo, you didn't git clone", repo.GoPath()) + os.Exit(-1) + } + if !me.forge.FinalGoDepsCheckOk(check) { + fixGodeps(check) + } + } + } + + // now figure out what to release and increment the version + loop = me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + // find the gitpb.Repo + check := me.forge.Repos.FindByGoPath(repo.GoPath()) + if check == nil { + log.Info("boo, you didn't git clone", repo.GoPath()) + os.Exit(-1) + } + + // if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" { + if check.GetGoPath() == "go.wit.com/gui" { + log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive) + if me.forge.FinalGoDepsCheckOk(check) { + log.Info("arg final check true", check.GetGoPath()) + } else { + log.Info("arg final check false", check.GetGoPath()) + // os.Exit(-1) + } + // see if there is a new version + master := repo.Status.GetMasterVersion() + lastTag := repo.Status.LastTag() + log.Info("arg ", master, lastTag) + // os.Exit(-1) + } + // check if the package dependancies changed, if so, re-publish + if !check.GoPrimitive { + if me.forge.FinalGoDepsCheckOk(check) { + log.Printf("go.sum is perfect! %s\n", check.GetGoPath()) + } else { + log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath()) + repo.Status.IncrementRevisionVersion("godeps changed") + target := repo.Status.GetTargetVersion() + check.SetTargetVersion(target) + } + } + + // see if there is a new version + master := repo.Status.GetMasterVersion() + lastTag := repo.Status.LastTag() + if master == lastTag { + repo.Status.SetTargetVersion(master) + } else { + repo.Status.IncrementRevisionVersion("Nov 2024 test") + target := repo.Status.GetTargetVersion() + check.SetTargetVersion(target) + } + // if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" { + // if check.GetGoPath() == "go.wit.com/gui" { + if check.GetGoPath() == "go.wit.com/dev/davecgh/spew" { + log.Info(repo.StandardReleaseHeader()) + log.Info(me.forge.StandardReleaseHeader(check, repo.State())) + log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive) + if me.forge.FinalGoDepsCheckOk(check) { + log.Info("go.sum is perfect") + } else { + log.Info("go.sum check false") + } + // see if there is a new version + master := repo.Status.GetMasterVersion() + lastTag := repo.Status.LastTag() + log.Info("arg ", master, lastTag) + if master != lastTag { + os.Exit(-1) + } + } + } + findNext() +} -- cgit v1.2.3