From 1c8815685b1a12e6d9856ef90b6c8d7f243c0744 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 2 Dec 2024 07:00:28 -0600 Subject: [PATCH] continue to migrate to protobuf package --- doRelease.go | 34 ++++++++-------- findNext.go | 18 ++++++++- globalDisplayOptions.go | 49 ----------------------- http.go | 4 +- human.go | 87 +++++++++++++++++++++++++++++++++++++++++ makePrepareRelease.go | 52 ++++++++++++++++++++++++ setTargetVersion.go | 9 +---- 7 files changed, 176 insertions(+), 77 deletions(-) create mode 100644 human.go create mode 100644 makePrepareRelease.go diff --git a/doRelease.go b/doRelease.go index e350db3..a7fe903 100644 --- a/doRelease.go +++ b/doRelease.go @@ -98,6 +98,19 @@ func doRelease() bool { return false } + pb := me.forge.Repos.FindByGoPath(me.current.GoPath()) + if pb != nil { + pb.UpdatePublished() + if !pb.GetGoPrimitive() { + loop := pb.Published.SortByGoPath() + for loop.Scan() { + t := loop.Next() + log.Info("new Published dep:", t.GetGoPath(), t.GetVersion()) + } + } + me.forge.Repos.ConfigSave() + } + log.Info("PUBLISH OK") // me.current.SetGoState("RELEASED") @@ -121,26 +134,11 @@ func doRelease() bool { } log.Info("EVERYTHING OK. RERELEASED", me.current.Name()) + // recreate go.mod / go.sum + fixGodeps(me.current) + // update the values in the GUI me.current.NewScan() - pb := me.forge.Repos.FindByGoPath(me.current.GoPath()) - if pb != nil { - pb.ParseGoSum() - if pb.Published != nil { - loop := pb.Published.SortByGoPath() - for loop.Scan() { - t := loop.Next() - log.Info("orig Published dep:", t.GetGoPath(), t.GetVersion()) - } - } - pb.UpdatePublished() - loop := pb.Published.SortByGoPath() - for loop.Scan() { - t := loop.Next() - log.Info("new Published dep:", t.GetGoPath(), t.GetVersion()) - } - me.forge.Repos.ConfigSave() - } // attempt to find another repo to release if !doReleaseFindNext() { diff --git a/findNext.go b/findNext.go index 9ffb6b7..e67b02a 100644 --- a/findNext.go +++ b/findNext.go @@ -115,7 +115,23 @@ func fixGodeps(repo *repolist.RepoRow) bool { log.Info("boo, you didn't git clone", repo.GoPath()) os.Exit(-1) } - check.RedoGoMod() + // skip primative ones + if check.GetGoPrimitive() { + return true + } + ok, err := check.RedoGoMod() + if err != nil { + return false + } + if !ok { + log.Info("gitpb.RedoGoMod() returned false", check.GetGoPath()) + return false + } + if check.GoDeps == nil { + cmd := []string{"go", "mod", "edit", "-go=1.20"} + check.Run(cmd) + return true + } log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen()) deps := check.GoDeps.SortByGoPath() for deps.Scan() { diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index ed26177..19d366c 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -1,8 +1,6 @@ package main import ( - "os" - "go.wit.com/gui" "go.wit.com/lib/debugger" "go.wit.com/lib/gui/logsettings" @@ -43,50 +41,3 @@ func globalDisplayOptions(box *gui.Node) { debugger.DebugWindow() }) } - -func makePrepareRelease() { - me.Disable() - me.release.box.Disable() - defer me.Enable() - loop := me.repos.View.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - // check if the package dependancies changed, if so, re-publish - check := me.forge.Repos.FindByGoPath(repo.GoPath()) - if check == nil { - log.Info("boo, you didn't git clone", repo.GoPath()) - os.Exit(-1) - } - match, err := me.forge.Repos.GoDepsChanged(check) - if err != nil { - log.Info("dependancy checks failed", check.GetGoPath(), err) - repo.Status.IncrementRevisionVersion("missing prior published godeps") - continue - } - if match { - log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath()) - repo.Status.IncrementRevisionVersion("godeps changed") - continue - } else { - log.Printf("dependancies have not changed for %s\n", check.GetGoPath()) - } - - // 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") - } - } - findNext() - if setAllBranchesToMaster() { - // if it succeeds, disable this button - me.setBranchesToMasterB.Disable() - me.release.box.Enable() - me.repos.View.PrintReleaseReport("", "") - } else { - log.Info("setAllBranchesToMaster() failed") - } -} diff --git a/http.go b/http.go index 924ec1d..d43efac 100644 --- a/http.go +++ b/http.go @@ -228,9 +228,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) { log.Info(repolist.ReleaseReportHeader()) log.Info(me.current.StandardReleaseHeader()) case "/list": - me.repos.View.PrintReport(readonly, onlydirty, perfect) + PrintReport(readonly, onlydirty, perfect) case "/releaseList": - me.repos.View.PrintReleaseReport(readonly, perfect) + PrintReleaseReport(readonly, perfect) case "/quit": log.Info("Got URL /quit") os.Exit(0) diff --git a/human.go b/human.go new file mode 100644 index 0000000..c204aed --- /dev/null +++ b/human.go @@ -0,0 +1,87 @@ +package main + +import ( + "fmt" + + "go.wit.com/lib/gui/repolist" + "go.wit.com/log" +) + +func PrintReport(readonly string, onlydirty string, perfect string) { + var count int + + log.Info(repolist.ReportHeader()) + + loop := me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + + count += 1 + header := repo.StandardHeader() + if onlydirty == "true" { + if repo.CheckDirty() { + log.Info(header + "") + } + continue + } + + if repo.ReadOnly() { + if readonly == "true" { + log.Info(header + "readonly") + } + continue + } + if repo.State() == "PERFECT" { + if perfect == "false" { + continue + } + } + if repo.State() != "merge to main" { + log.Info(header + "") + continue + } + if repo.CheckDirty() { + log.Info(header + "") + continue + } + log.Info(header + "") + check := me.forge.Repos.FindByGoPath(repo.GoPath()) + if check == nil { + log.Info("boo, you didn't git clone", repo.GoPath()) + continue + } + me.forge.StandardReleaseHeader(check, repo.State()) + } + log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count)) +} + +func PrintReleaseReport(readonly string, perfect string) { + var count int + + log.Info(repolist.ReleaseReportHeader()) + + loop := me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + + if repo.ReadOnly() && (readonly == "true") { + continue + } + if (repo.State() == "PERFECT") && (perfect == "true") { + continue + } + if repo.Status.IsReleased() { + 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()) + continue + } + log.Info(me.forge.StandardReleaseHeader(check, repo.State())) + } + log.Info(fmt.Sprintf("total repo count = %d", count)) +} diff --git a/makePrepareRelease.go b/makePrepareRelease.go new file mode 100644 index 0000000..645ea57 --- /dev/null +++ b/makePrepareRelease.go @@ -0,0 +1,52 @@ +package main + +import ( + "os" + + "go.wit.com/log" +) + +func makePrepareRelease() { + me.Disable() + me.release.box.Disable() + defer me.Enable() + loop := me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + // check if the package dependancies changed, if so, re-publish + 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.FinalGoDepsCheck(check) { + 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 + } else { + log.Printf("dependancies have not changed for %s\n", check.GetGoPath()) + } + + // 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) + } + } + findNext() + if setAllBranchesToMaster() { + // if it succeeds, disable this button + me.setBranchesToMasterB.Disable() + me.release.box.Enable() + PrintReleaseReport("", "") + } else { + log.Info("setAllBranchesToMaster() failed") + } +} diff --git a/setTargetVersion.go b/setTargetVersion.go index 24388a6..0d53fb2 100644 --- a/setTargetVersion.go +++ b/setTargetVersion.go @@ -1,12 +1,6 @@ package main -import ( - "os" - "strings" - - "go.wit.com/log" -) - +/* func setTargetVersion() { // go through and set the target versions for each repo // todo: add sanity checking in repolist to verify these and/or autocompute them @@ -76,3 +70,4 @@ func incrementTargetVersion() bool { } return false } +*/