From b07ef2498f839e06e66580bf894ce6e34be31c10 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 2 Feb 2024 03:34:14 -0600 Subject: [PATCH] start the automation of version re-release Signed-off-by: Jeff Carr --- releaseWindow.go | 2 +- unreleaseWindow.go | 149 +++++++++++++++++++++++++++------------------ 2 files changed, 92 insertions(+), 59 deletions(-) diff --git a/releaseWindow.go b/releaseWindow.go index 97073a0..3476f9e 100644 --- a/releaseWindow.go +++ b/releaseWindow.go @@ -338,7 +338,7 @@ func goodCheckGoSum() bool { tmp := release.current.String() log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.getGoSumStatus()) /* - */ + */ var maybe bool = true goConfig := release.current.status.GetGoDeps() diff --git a/unreleaseWindow.go b/unreleaseWindow.go index 46894f8..1373815 100644 --- a/unreleaseWindow.go +++ b/unreleaseWindow.go @@ -8,73 +8,56 @@ import ( "go.wit.com/log" ) +func findUnreleased() bool { + for _, repo := range me.allrepos { + if whitelist(repo.String()) { + log.Info("skipping whitelist", repo.String()) + continue + } + setCurrentRepo(repo, "rewind this?", "not sure") + + if repo.lookToUnwind() { + log.Info("found something to unwind:", repo.String()) + if setCurrentRepo(repo, "rewind this", "very sure") { + return true + } + return false + } + } + return false +} + func createUnreleaseBox(box *gui.Node) { group := release.box.NewGroup("undo and redo things") group.NewButton("find the unreleased", func() { me.Disable() defer me.Enable() - for _, repo := range me.allrepos { - if whitelist(repo.String()) { - log.Info("skipping whitelist", repo.String()) - continue - } - setCurrentRepo(repo, "rewind this?", "not sure") - - if repo.lookToUnwind() { - log.Info("found something to unwind:", repo.String()) - if setCurrentRepo(repo, "rewind this", "very sure") { - } + findUnreleased() + }) + release.unreleaseB = group.NewButton("re-release", func() { + // var count int = 0 + me.Disable() + if rerelease() { + log.Info("good to re-release another one") + } else { + log.Info("loop(3) failed") + return + } + me.Enable() + }) + group.NewButton("loop(5)", func() { + me.Disable() + for n := 0; n <= 5; n++ { + if rerelease() { + log.Info("good to re-release another one") + } else { + log.Info("loop(3) failed") return } } - }) - release.unreleaseB = group.NewButton("re-release", func() { - me.Disable() - if release.unreleaseB.String() != "un-release version "+release.version.String() { - log.Warn("something went wrong with the release.version:", release.version.String()) - return - } - - if strings.HasPrefix(release.version.String(), "v") { - log.Warn("everything is ok. version starts with v.", release.version.String()) - } else { - log.Warn("version does not start with v.", release.version.String()) - return - } - - if release.current.status.CheckDirty() { - log.Info("sorry, it's still dirty") - return - } - - curName := release.current.status.GetCurrentBranchName() - mName := release.current.status.GetMasterBranchName() - if curName != mName { - log.Info("\trepo is not working from main branch", curName, "!=", mName) - return - } - - log.Info("\treset to devel", curName, release.version.String(), release.reasonS) - - var all [][]string - all = append(all, []string{"git", "checkout", "devel"}) - all = append(all, []string{"git", "branch", "-D", mName}) - all = append(all, []string{"git", "branch", mName}) - all = append(all, []string{"git", "checkout", mName}) - all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName}) - - all = append(all, []string{"git", "tag", "--delete", release.version.String()}) - all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()}) - all = append(all, []string{"git", "tag", "-m", release.reasonS, release.version.String()}) - all = append(all, []string{"git", "push", "origin", release.version.String()}) - - if doAll(release.current, all) { - log.Info("EVERYTHING OK") - me.Enable() - } else { - log.Info("SOMETHING FAILED") - } + log.Info("loop(5) worked") + me.Enable() }) } @@ -90,3 +73,53 @@ func doAll(r *repo, all [][]string) bool { } return true } +func rerelease() bool { + if release.unreleaseB.String() != "un-release version "+release.version.String() { + log.Warn("something went wrong with the release.version:", release.version.String()) + return false + } + + if strings.HasPrefix(release.version.String(), "v") { + log.Warn("everything is ok. version starts with v.", release.version.String()) + } else { + log.Warn("version does not start with v.", release.version.String()) + return false + } + + if release.current.status.CheckDirty() { + log.Info("sorry, it's still dirty") + return false + } + + curName := release.current.status.GetCurrentBranchName() + mName := release.current.status.GetMasterBranchName() + if curName != mName { + log.Info("\trepo is not working from main branch", curName, "!=", mName) + return false + } + + log.Info("\treset to devel", curName, release.version.String(), release.reasonS) + + var all [][]string + all = append(all, []string{"git", "checkout", "devel"}) + all = append(all, []string{"git", "branch", "-D", mName}) + all = append(all, []string{"git", "branch", mName}) + all = append(all, []string{"git", "checkout", mName}) + all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName}) + + all = append(all, []string{"git", "tag", "--delete", release.version.String()}) + all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()}) + all = append(all, []string{"git", "tag", "-m", release.reasonS, release.version.String()}) + all = append(all, []string{"git", "push", "origin", release.version.String()}) + + if doAll(release.current, all) { + log.Info("EVERYTHING OK. RERELEASED", release.current.String()) + if findUnreleased() { + log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.String()) + } + } else { + log.Info("SOMETHING FAILED") + return false + } + return true +}