don't os.exit anymore as often

This commit is contained in:
Jeff Carr 2024-12-15 17:03:51 -06:00
parent 24ddb803f3
commit 8e9408bac8
Notes: Jeff Carr 2024-12-15 17:05:42 -06:00
// `autogen:go.mod`

module go.wit.com/apps/guireleaser

go 1.21

toolchain go1.23.4

require (
	github.com/go-cmd/cmd v1.4.3
	go.wit.com/dev/alexflint/arg v1.5.5
	go.wit.com/gui v0.22.14
	go.wit.com/lib/debugger v0.22.5
	go.wit.com/lib/gadgets v0.22.5
	go.wit.com/lib/gui/logsettings v0.22.5
	go.wit.com/lib/gui/repolist v0.22.34
	go.wit.com/lib/gui/shell v0.22.17
	go.wit.com/lib/protobuf/forgepb v0.0.33
	go.wit.com/lib/protobuf/gitpb v0.0.31
	go.wit.com/log v0.22.9
)

require (
	github.com/destel/rill v0.6.0 // indirect
	github.com/google/uuid v1.6.0 // indirect
	go.wit.com/dev/alexflint/scalar v1.2.4 // indirect
	go.wit.com/lib/gui/repostatus v0.22.29 // indirect
	go.wit.com/lib/protobuf/virtbuf v0.2.16 // indirect
	go.wit.com/lib/protobuf/zoopb v0.0.19 // indirect
	go.wit.com/widget v1.1.27 // indirect
	google.golang.org/protobuf v1.35.2 // indirect
)

// `autogen:go.sum`

github.com/destel/rill v0.6.0 h1:8MQRzS6k0akKmwNZFahKIhG1dkBeNxMoWKSfOxkaJNw=
github.com/destel/rill v0.6.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4=
github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y=
github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.wit.com/dev/alexflint/arg v1.5.5 h1:c4jgIb4OvHjnCMRNSjOa1sNLl6WDxV6tIkMVezR9hCk=
go.wit.com/dev/alexflint/arg v1.5.5/go.mod h1:nH3F6TJDaAUgnLkC0WgRN/H047YfN1TYKaWPYr6B8lo=
go.wit.com/dev/alexflint/scalar v1.2.4 h1:zmBeEkObwz1lcelwfGNYP2GS6SQ9e0tdv7JdHwMZEEk=
go.wit.com/dev/alexflint/scalar v1.2.4/go.mod h1:kCNO1Fo5LnnK6+qa+zYhP5fdgfC1C+vx1ti99Md+FAM=
go.wit.com/gui v0.22.14 h1:Ssio1XxZvLB8vzaL0Wxak2Tq9plG5lPtmDcFUz9+4jU=
go.wit.com/gui v0.22.14/go.mod h1:U7Bw4dw+x+sfHhru/jKS9I5APxXdiQIF5B2luJH1cE8=
go.wit.com/lib/debugger v0.22.5 h1:kq5XpoLkVYEQmW4r4y6GZPwO1iItDhlNOU2BT0IGc3I=
go.wit.com/lib/debugger v0.22.5/go.mod h1:+Q1NWiEIjoRzy7cN6c/D0/QcPgdIzYCSxbC8Gaht7mw=
go.wit.com/lib/gadgets v0.22.5 h1:sDBSIVb+MflU705ImwKFvP9hnnZdLVrwy+Xsgp/w7dw=
go.wit.com/lib/gadgets v0.22.5/go.mod h1:Hiap8lateez6bts/DFmu+HSX9y8rgCfmusnG/CiTuGM=
go.wit.com/lib/gui/logsettings v0.22.5 h1:rBv86U4xB5C/t+itqmH8CfXQ5cb+MaIc8E2Z8iCU2E4=
go.wit.com/lib/gui/logsettings v0.22.5/go.mod h1:6Rb0bMC56sdtUbJh/Z7DsRqNH4IHYm5MDbqA3f32KAY=
go.wit.com/lib/gui/repolist v0.22.34 h1:q9u2VVKeruYbvLwcPPyeQf8JhcL0/IhrfeptWkbW/sM=
go.wit.com/lib/gui/repolist v0.22.34/go.mod h1:TI6554E3XKsK+ES4LVzZUwAI8O0HFA6giu/SJyF7i3w=
go.wit.com/lib/gui/repostatus v0.22.29 h1:WKcGUBqGMnk/cjOV4G6aQGggT8oH4imRzgI601P3SIY=
go.wit.com/lib/gui/repostatus v0.22.29/go.mod h1:uw1PuOvoU053UZeWBzUW171qVFteZrfpNzsEuTJuP+4=
go.wit.com/lib/gui/shell v0.22.17 h1:JfGozzkhrlCDCtQCVgVExobvseFc2ZIM9r76cXCouwg=
go.wit.com/lib/gui/shell v0.22.17/go.mod h1:zduuMSWq+EE7w0xbXn+vkoGZ4HJhURVJpvXw8oK9WAU=
go.wit.com/lib/protobuf/forgepb v0.0.33 h1:XeJsQwjwJ9rmLLvhO+kkds0yDRcG4oI60fiEDDes+3Q=
go.wit.com/lib/protobuf/forgepb v0.0.33/go.mod h1:VnHJvgDlIGtgvMokv8N2OtHYTnRrukyFFX1k5Uug/2g=
go.wit.com/lib/protobuf/gitpb v0.0.31 h1:jnNGwnThZYLvRjZgLN+h5j5A99zoSD9dHd9UzgpEtUM=
go.wit.com/lib/protobuf/gitpb v0.0.31/go.mod h1:ufUa44/Y+0I5g+fX1nz995EEsKJ8apPpMtPTC3LXJu4=
go.wit.com/lib/protobuf/virtbuf v0.2.16 h1:KWg23MXxo9ZNbnJNzuHf3SlG6wMvwuhDsYQ2x1oAgYU=
go.wit.com/lib/protobuf/virtbuf v0.2.16/go.mod h1:ec2g2Ld9ojFN7ws6Vx7kJ/F3WB9PhHulNoD9SWPfAQw=
go.wit.com/lib/protobuf/zoopb v0.0.19 h1:sC5l0gs20adoV/zws7VEYlPhmgB77TvyzSK2XY2r5NI=
go.wit.com/lib/protobuf/zoopb v0.0.19/go.mod h1:bdeHyuJI//suaWh97S0G2dBK46+e0gQk0u9nL3yfAcI=
go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y=
go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ=
go.wit.com/widget v1.1.27 h1:Yd+qp6GZVwLiTTepShXSeWSDqjaCxLyfhU0ch2FrPZ8=
go.wit.com/widget v1.1.27/go.mod h1:OXIdWk7GhVJRLnHTvf45LbPNXGYG/JjbkfnmXtkoiYE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

// `autogen:`
5 changed files with 46 additions and 24 deletions

View File

@ -2,6 +2,8 @@
package main package main
import ( import (
"errors"
"fmt"
"os" "os"
"strings" "strings"
"time" "time"
@ -51,15 +53,16 @@ func doRelease() bool {
return false return false
} }
if !me.forge.FinalGoDepsCheckOk(check) { if !me.forge.FinalGoDepsCheckOk(check) {
log.Info("the go.mod file is wrong. fix it here?", check.GetGoPath()) msg := fmt.Sprint("the go.mod file is wrong. fix it here?", check.GetGoPath())
os.Exit(-1) badExit(errors.New(msg))
return false return false
} }
if check.GoPath == me.startRepo.GoPath { if check.GoPath == me.startRepo.GoPath {
log.Info("CAN NOT SELF UPDATE.", check.GoPath, "is the same as os.Getwd()") 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("go get must be run from somewhere else other than startRepo")
log.Info("chdir to autotypist if it exists") log.Info("chdir to autotypist if it exists")
os.Exit(-1) msg := fmt.Sprint("CAN NOT SELF UPDATE.", check.GoPath, "is the same as os.Getwd()")
badExit(errors.New(msg))
} }
if !me.startRepo.Exists("go.mod") { if !me.startRepo.Exists("go.mod") {
log.Info("go.sum missing in", me.startRepo.GoPath) log.Info("go.sum missing in", me.startRepo.GoPath)
@ -73,7 +76,8 @@ func doRelease() bool {
if err := check.ValidGoSum(); err != nil { if err := check.ValidGoSum(); err != nil {
log.Info("ValidGoSum() error", check.GoPath, err) log.Info("ValidGoSum() error", check.GoPath, err)
os.Exit(-1) msg := fmt.Sprint("ValidGoSum() error", check.GoPath, err)
badExit(errors.New(msg))
} }
var all [][]string var all [][]string
@ -91,7 +95,8 @@ func doRelease() bool {
if err != nil { if err != nil {
log.Info("\tERROR: There are protobuf files, but they are not compiled") log.Info("\tERROR: There are protobuf files, but they are not compiled")
log.Info("\tERROR: can not continue") log.Info("\tERROR: can not continue")
os.Exit(-1) msg := fmt.Sprint("ERROR: There are protobuf files, but they are not compiled")
badExit(errors.New(msg))
} }
log.Info("\tshould add the protobuf files here") log.Info("\tshould add the protobuf files here")
log.Info("\tcompiled files found:", compiled) log.Info("\tcompiled files found:", compiled)
@ -112,7 +117,8 @@ func doRelease() bool {
cname := check.GetCurrentBranchName() cname := check.GetCurrentBranchName()
if err := check.AutogenSave(autogen, cname, true); err != nil { if err := check.AutogenSave(autogen, cname, true); err != nil {
log.Info("AutogenSave() error", err) log.Info("AutogenSave() error", err)
os.Exit(-1) msg := fmt.Sprint("AutogenSave() error", err)
badExit(errors.New(msg))
} }
if !me.current.Status.DoAll(all) { if !me.current.Status.DoAll(all) {
@ -145,7 +151,6 @@ func doRelease() bool {
} }
} }
*/ */
me.forge.Repos.ConfigSave()
} }
log.Info("PUBLISH OK") log.Info("PUBLISH OK")
@ -181,7 +186,8 @@ func doRelease() bool {
newtag := me.release.version.String() newtag := me.release.version.String()
if err := check.AutogenSave(autogen, newtag, true); err != nil { if err := check.AutogenSave(autogen, newtag, true); err != nil {
log.Info("AutogenSave() error", err) log.Info("AutogenSave() error", err)
os.Exit(-1) msg := fmt.Sprint("AutogenSave() error", err)
badExit(errors.New(msg))
} }
// it's necessary to recreate the the files here // it's necessary to recreate the the files here
@ -253,7 +259,8 @@ func doPublishVersion() bool {
log.Info("CAN NOT SELF UPDATE. cmd =", docmd) log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
log.Info("go get must be run from somewhere else other than startRepo") log.Info("go get must be run from somewhere else other than startRepo")
log.Info("chdir to autotypist if it exists") log.Info("chdir to autotypist if it exists")
os.Exit(-1) msg := fmt.Sprint("CAN NOT SELF UPDATE. cmd =", docmd)
badExit(errors.New(msg))
} }
// publish go.mod & go.sum for use with go // publish go.mod & go.sum for use with go
os.Unsetenv("GO111MODULE") os.Unsetenv("GO111MODULE")

18
exit.go Normal file
View File

@ -0,0 +1,18 @@
package main
import (
"os"
"go.wit.com/log"
)
func okExit(thing string) {
log.Info(thing, "ok")
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
os.Exit(0)
}
func badExit(err error) {
log.Info("forge failed: ", err, me.forge.GetGoSrc())
os.Exit(-1)
}

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
@ -178,10 +179,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
case "/releaseList": case "/releaseList":
PrintReleaseReport(readonly, perfect) PrintReleaseReport(readonly, perfect)
return return
case "/quit":
log.Info("Got URL /quit")
os.Exit(0)
return
case "/goweblist": case "/goweblist":
loop := me.repos.View.ReposAll() loop := me.repos.View.ReposAll()
for loop.Scan() { for loop.Scan() {
@ -289,8 +286,8 @@ func showNext() {
if ok, compiled, err := me.current.IsProtobuf(); ok { if ok, compiled, err := me.current.IsProtobuf(); ok {
log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled)) log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled))
if err != nil { if err != nil {
log.Info(log.Sprint("IsProtobuf() == err", err)) msg := fmt.Sprint("IsProtobuf() == err", err)
os.Exit(-1) badExit(errors.New(msg))
} }
for _, s := range compiled { for _, s := range compiled {
log.Info("\tcompiled file found:", s) log.Info("\tcompiled file found:", s)

12
main.go
View File

@ -2,6 +2,8 @@ package main
import ( import (
"embed" "embed"
"errors"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -35,8 +37,7 @@ func main() {
me.releaseReasonS = os.Getenv("GUIRELEASE_REASON") me.releaseReasonS = os.Getenv("GUIRELEASE_REASON")
if me.releaseReasonS == "" { if me.releaseReasonS == "" {
log.Info("shell ENV GUIRELEASE_REASON not set") badExit(errors.New("shell ENV GUIRELEASE_REASON not set"))
os.Exit(0)
} }
// unset the go development ENV var to generate release files // unset the go development ENV var to generate release files
@ -62,8 +63,7 @@ func main() {
homeDir, _ := os.UserHomeDir() homeDir, _ := os.UserHomeDir()
gowork := filepath.Join(homeDir, "go/src/go.work") gowork := filepath.Join(homeDir, "go/src/go.work")
if shell.Exists(gowork) { if shell.Exists(gowork) {
log.Info("go.work must be deleted") badExit(errors.New("go.work must be deleted"))
os.Exit(0)
} }
log.Info("Creating the Release Window") log.Info("Creating the Release Window")
@ -118,8 +118,8 @@ func main() {
me.startRepo = me.forge.Repos.FindByGoPath(basedir) me.startRepo = me.forge.Repos.FindByGoPath(basedir)
if me.startRepo == nil { if me.startRepo == nil {
log.Info("Can not run if pwd is not a repo", basedir) msg := fmt.Sprint("Can not run if pwd is not a repo", basedir)
os.Exit(0) badExit(errors.New(msg))
} }
me.Enable() me.Enable()

View File

@ -139,7 +139,7 @@ func createReleaseBox(box *gui.Node) {
log.Info("doReleaseAll() first =", first, "second =", second) log.Info("doReleaseAll() first =", first, "second =", second)
if first == 0 { if first == 0 {
log.Info("doReleaseAll() first is 0. everything is done") log.Info("doReleaseAll() first is 0. everything is done")
log.Info("os.Exit(0) here safely") log.Info("exit() here safely")
buttonEnable() buttonEnable()
return return
} }
@ -159,6 +159,7 @@ func createReleaseBox(box *gui.Node) {
if (second == 0) && (third == 0) { if (second == 0) && (third == 0) {
log.Info("doReleaseAll() SaveConfig() here and Exit(0)") log.Info("doReleaseAll() SaveConfig() here and Exit(0)")
me.forge.ConfigSave() me.forge.ConfigSave()
okExit("")
} }
} else { } else {
log.Info("doReleaseAll() first second match. something has gone terribly wrong") log.Info("doReleaseAll() first second match. something has gone terribly wrong")
@ -253,12 +254,11 @@ func doReleaseAll() (bool, time.Duration) {
if os.Getenv("FindNextDone") == "true" { if os.Getenv("FindNextDone") == "true" {
log.Info("findNext says it was done. findCounter =", findCounter) log.Info("findNext says it was done. findCounter =", findCounter)
log.Info("findNext says it was done. findCounter =", findCounter) log.Info("findNext says it was done. findCounter =", findCounter)
log.Info("we can os.Exit here") log.Info("we can exit here")
} }
if me.release.status.String() == "ALL DONE?" { if me.release.status.String() == "ALL DONE?" {
log.Info("maybe ALL DONE?. findCounter =", findCounter) log.Info("maybe ALL DONE?. findCounter =", findCounter)
worked = true worked = true
// os.Exit(0)
} }
log.Info("doRelease() failed. findCounter =", findCounter) log.Info("doRelease() failed. findCounter =", findCounter)
worked = false worked = false