don't os.exit anymore as often
This commit is contained in:
parent
24ddb803f3
commit
8e9408bac8
25
doRelease.go
25
doRelease.go
|
@ -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")
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
9
http.go
9
http.go
|
@ -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
12
main.go
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue