package main import ( "os" "go.wit.com/log" "go.wit.com/lib/protobuf/gitpb" ) var findCounter int var findFix bool = false var findOk bool = 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 { findCounter = 0 all := me.found.SortByFullPath() for all.Scan() { check := all.Next() if check.GetMasterBranchName() != check.GetCurrentBranchName() { log.Info("FIND NEXT: YOU MUST BE ON THE MASTER BRANCH", check.GetNamespace()) continue } if check.IsDirty() { log.Info("FIND NEXT: CAN NOT RELEASE DIRTY REPO", check.GetNamespace()) continue } if alreadyDone(check) { log.Info("FIND NEXT: findNext() alreadyDone. WHY IS THIS STILL CHECKING?", check.GetNamespace()) continue } log.Info("FIND NEXT: CHECKING START:", check.GetNamespace()) if me.forge.Config.IsPrivate(check.GetNamespace()) { log.Info("FIND NEXT: GOOD TO GO ON PRIVATE REPO", check.GetNamespace()) setCurrentRepo(check, "should be good to release", "pretty sure") return true } godepsNew, err := check.GoSumFromRepo() if err != nil { log.Info("FIND NEXT: CHECKING go deps from repo failed", err) continue } if godepsNew == nil { // don't check godepsNew, but check to make sure go mod tidy actually ran without error os.Unsetenv("GO111MODULE") cmd := []string{"go", "mod", "tidy"} err := check.RunVerbose(cmd) if err != nil { log.Info("FIND NEXT: go mod tidy failed. this go package needs to be examined by hand as it doesn't appear to be primitive") log.Info("FIND NEXT:", check.FullPath, cmd) os.Exit(-1) } // if godepsNew == nil, then this go package is a primitive and there is no go.sum file } else { if err := testGoDepsCheckOk(godepsNew); err != nil { log.Info("FIND NEXT: CHECKING current repo deps failed", err) continue } } if err := finalGoDepsCheckOk(check); err != nil { // if err := me.forge.FinalGoDepsCheckOk(check, false); err != nil { log.Info("FIND NEXT: FinalGoDepsCheckOk() repo=", check.GetNamespace(), "err:", err) log.Info("FIND NEXT: CHECKING END:", check.GetNamespace()) log.Info("FIND NEXT: ") continue } log.Info("FIND NEXT: GOOD TO GO ON", check.GetNamespace()) setCurrentRepo(check, "should be good to release", "pretty sure") return true } if findCounter == 0 { log.Info("FIND NEXT: NOTHING TO UPDATE. findCounter =", findCounter, "found len =", me.found.Len()) if me.found.Len() == 0 { printDone() okExit("") } } else { log.Info("FIND NEXT: me.current is nil findCounter =", findCounter, "so set findFix =", findFix) } log.Info("FIND NEXT: tried to findNext() but not sure what to do next counter =", findCounter, "findFix =", findFix) setCurrentRepo(nil, "FIND NEXT: findNext found nothing", "crap") me.release.status.SetText("FIND NEXT: ALL DONE?") return false } func setCurrentRepo(check *gitpb.Repo, s string, note string) bool { me.current = check if check == nil { me.release.repo.SetText("") me.release.version.SetText("") me.release.releaseVersionB.SetText("repo == nil") me.release.version.SetText("repo == nil") } else { me.release.repo.SetText(check.GetNamespace()) me.release.version.SetText(check.GetTargetVersion()) me.release.releaseVersionB.SetText("release version " + check.GetTargetVersion()) me.release.version.SetText(check.GetTargetVersion()) } me.release.status.SetText(s) me.release.notes.SetText(note) // me.release.openrepo.Enable() return true }