From a68b3400a5d63f587e11d6b2505bfdd48b461cd8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 8 Nov 2024 06:45:12 -0600 Subject: [PATCH] use go-cmd/cmd --- doRelease.go | 68 +++++++++++++++++++++++++++------------------------ releaseBox.go | 4 +-- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/doRelease.go b/doRelease.go index a6fb2a7..17efc39 100644 --- a/doRelease.go +++ b/doRelease.go @@ -6,6 +6,8 @@ import ( "path/filepath" "strings" + "github.com/go-cmd/cmd" + "go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/shell" "go.wit.com/log" @@ -149,12 +151,12 @@ func doReleaseFindNext() bool { // to insert the new version func doPublishVersion() bool { gopath := me.current.GoPath() - cmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()} - log.Info("SHOULD RUN cmd HERE:", cmd) + docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()} + log.Info("SHOULD RUN cmd HERE:", docmd) // right now, you can't publish this because the go.* files in this project are screwed up if me.release.guireleaser == nil { - log.Info("CAN NOT SELF UPDATE HERE. cmd =", cmd) + log.Info("CAN NOT SELF UPDATE HERE. cmd =", docmd) return false } homeDir, _ := os.UserHomeDir() @@ -163,37 +165,39 @@ func doPublishVersion() bool { log.Info("go.sum must exist here") me.release.guireleaser.Status.MakeRedomod() } - var err error - var out string if me.current.Status.IsPrivate() { // do not self update private repos - err = nil - out = "This is a private repo and can not be self checked" - } else { - if gopath == "go.wit.com/apps/guireleaser" { - log.Info("CAN NOT SELF UPDATE. cmd =", cmd) - log.Info("go get must be run from somewhere else other than guireleaser") - err, ok, output := shell.RunCmd("", cmd) - log.Info("err =", err) - log.Info("ok =", ok) - log.Info("output =", output) - } else { - // publish go.mod & go.sum for use with go - os.Unsetenv("GO111MODULE") - log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd) - err, out = me.release.guireleaser.Status.RunCmd(cmd) - if gopath == "go.wit.com/apps/guireleaser" { - // ignore errors on updating myself - log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd) - err = nil - } - } - } - if err == nil { - log.Info("SELF UPDATE OK. out =", out) - log.Info("SELF UPDATE WORKED") - // me.current.SetGoState("RELEASED") + log.Info("This is a private repo and can not be self checked") return true } - return false + + // try to pull from google + var result cmd.Status + if gopath == "go.wit.com/apps/guireleaser" { + log.Info("CAN NOT SELF UPDATE. cmd =", docmd) + log.Info("go get must be run from somewhere else other than guireleaser") + result = shell.PathRun("/home/jcarr/go/src/go.wit.com/apps/autotypist", docmd) + } else { + // publish go.mod & go.sum for use with go + os.Unsetenv("GO111MODULE") + log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd) + result = me.release.guireleaser.Status.Run(docmd) + } + if result.Error != nil { + log.Info("SELF UPDATE FAILED. error =", result.Error) + log.Info("SELF UPDATE FAILED. exit =", result.Exit) + log.Info("SELF UPDATE FAILED. out =", result.Stdout) + log.Info("SELF UPDATE FAILED") + return false + } + if result.Exit != 0 { + log.Info("SELF UPDATE FAILED. error =", result.Error) + log.Info("SELF UPDATE FAILED. exit =", result.Exit) + log.Info("SELF UPDATE FAILED. out =", result.Stdout) + log.Info("SELF UPDATE FAILED") + return false + } + log.Info("SELF UPDATE OK. out =", result.Stdout) + log.Info("SELF UPDATE WORKED") + return true } diff --git a/releaseBox.go b/releaseBox.go index a3e0849..14b0c94 100644 --- a/releaseBox.go +++ b/releaseBox.go @@ -178,7 +178,7 @@ func createReleaseBox(box *gui.Node) { if repo.Status.ReadOnly() { continue } - repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"}) + repo.Status.Run([]string{"rm", "-f", "go.mod", "go.sum"}) } me.Enable() }) @@ -191,7 +191,7 @@ func createReleaseBox(box *gui.Node) { continue } log.Warn("running git reset --hard", repo.Name()) - repo.Status.RunCmd([]string{"git", "reset", "--hard"}) + repo.Status.Run([]string{"git", "reset", "--hard"}) } me.Enable() })