package main import ( "fmt" "os" "go.wit.com/log" "go.wit.com/lib/cobol" "go.wit.com/lib/protobuf/gitpb" ) // trys to figure out if there is still something to update // todo: redo this logic as it is terrible // rename this findNext() func findNext(found *gitpb.Repos) []*gitpb.Repo { var trythese []*gitpb.Repo // findCounter = 0 var simpletable [][]string simpletable = append(simpletable, []string{"namespace", "function", "err reason"}) for check := range found.IterAll() { 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()) simpletable = append(simpletable, []string{check.GetNamespace(), "CAN NOT RELEASE DIRTY REPO"}) 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()) trythese = append(trythese, check) continue } godepsNew, err := check.GoSumFromRepo() if err != nil { errs := fmt.Sprintf("%v", err) simpletable = append(simpletable, []string{check.GetNamespace(), "check.GoSumFromRepo()", errs}) 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: ") simpletable = append(simpletable, []string{check.GetNamespace(), fmt.Sprintf("FinalGoDepsCheckOk() err(%v)", err)}) continue } log.Info("FIND NEXT: GOOD TO GO ON", check.GetNamespace()) // setCurrentRepo(check, "should be good to release", "pretty sure") trythese = append(trythese, check) } footer := cobol.SimpleTable(simpletable) log.Info("reasons against publishing:", footer) return trythese }