move checks to panic in safer places

This commit is contained in:
Jeff Carr 2024-12-13 20:32:07 -06:00
parent d1708d6a4b
commit 1c8f55d397
3 changed files with 26 additions and 13 deletions

View File

@ -55,6 +55,19 @@ func doRelease() bool {
os.Exit(-1)
return false
}
if check.GoPath == me.startRepo.GoPath {
log.Info("CAN NOT SELF UPDATE.", check.GoPath, "is the same as os.Getwd()")
log.Info("go get must be run from somewhere else other than startRepo")
log.Info("chdir to autotypist if it exists")
os.Exit(-1)
}
if !me.startRepo.Exists("go.mod") {
log.Info("go.sum missing in", me.startRepo.GoPath)
log.Info("pick a different repo here")
log.Info("todo: error out earlier knowing this will upgrade")
log.Info("versions", me.startRepo.GetTargetVersion(), me.startRepo.GetMasterVersion())
panic("redo go.sum")
}
log.Info("\ttag and push", curName, me.release.version.String(), me.releaseReasonS)
@ -180,8 +193,10 @@ func doRelease() bool {
// attempt to find another repo to release
if !doReleaseFindNext() {
log.Info("doReleaseFindNext() could not find a new")
log.Info("THIS PROBABLY MEANS THAT ACTUALLY WE ARE TOTALLY DONE?")
log.Info("doReleaseFindNext() could not find a new", findCounter)
log.Info("THIS PROBABLY MEANS THAT ACTUALLY WE ARE TOTALLY DONE?", findCounter)
count := PrintReleaseReport("", "")
log.Info("count =", count)
os.Setenv("FindNextDone", "true")
return false
}
@ -226,13 +241,6 @@ func doPublishVersion() bool {
docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()}
log.Info("SHOULD RUN cmd HERE:", docmd)
if !me.startRepo.Exists("go.mod") {
log.Info("go.sum missing in", me.startRepo.GoPath)
log.Info("pick a different repo here")
log.Info("todo: error out earlier knowing this will upgrade")
log.Info("versions", me.startRepo.GetTargetVersion(), me.startRepo.GetMasterVersion())
panic("redo go.sum")
}
if me.current.Status.IsPrivate() {
// do not self update private repos
log.Info("This is a private repo and can not be self checked")
@ -243,7 +251,7 @@ func doPublishVersion() bool {
var result cmd.Status
if gopath == me.startRepo.GoPath {
log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
log.Info("go get must be run from somewhere else other than guireleaser")
log.Info("go get must be run from somewhere else other than startRepo")
log.Info("chdir to autotypist if it exists")
os.Exit(-1)
}

View File

@ -55,7 +55,7 @@ func PrintReport(readonly string, onlydirty string, perfect string) {
log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count))
}
func PrintReleaseReport(readonly string, perfect string) {
func PrintReleaseReport(readonly string, perfect string) int {
var count int
log.Info(repolist.ReleaseReportHeader())
@ -81,4 +81,5 @@ func PrintReleaseReport(readonly string, perfect string) {
log.Info(me.forge.StandardReleaseHeader(check, state))
}
log.Info(fmt.Sprintf("total repo count = %d", count))
return count
}

View File

@ -4,6 +4,7 @@ import (
"embed"
"os"
"path/filepath"
"strings"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
@ -111,10 +112,13 @@ func main() {
}
}
me.startRepo = me.forge.Repos.FindByGoPath("go.wit.com/apps/helloworld")
pwd, _ := os.Getwd()
basedir := strings.TrimPrefix(pwd, me.forge.GetGoSrc())
basedir = strings.Trim(basedir, "/")
me.startRepo = me.forge.Repos.FindByGoPath(basedir)
if me.startRepo == nil {
log.Info("Can not release if guireleaser was not found")
log.Info("Can not run if pwd is not a repo", basedir)
os.Exit(0)
}
me.Enable()