more attempts to release versions
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
732ac4b1e5
commit
21546ce2c0
34
draw.go
34
draw.go
|
@ -108,8 +108,29 @@ func (rs *RepoStatus) drawGitBranches() {
|
|||
}
|
||||
})
|
||||
|
||||
newgrid.NewButton("check go.sum", func() {
|
||||
rs.CheckGoSum()
|
||||
newgrid.NewButton("CheckDirty()", func() {
|
||||
if rs.CheckDirty() {
|
||||
log.Log(WARN, "is dirty")
|
||||
} else {
|
||||
log.Log(WARN, "is not dirty")
|
||||
}
|
||||
})
|
||||
newgrid.NewButton("CheckGoSum()", func() {
|
||||
if rs.CheckGoSum() {
|
||||
log.Log(WARN, "CheckGoSum() is ok")
|
||||
} else {
|
||||
log.Log(WARN, "CheckGoSum() is not ok")
|
||||
}
|
||||
})
|
||||
newgrid.NewButton("CheckPrimativeGoMod()", func() {
|
||||
if rs.CheckPrimativeGoMod() {
|
||||
log.Log(WARN, "is primative")
|
||||
} else {
|
||||
log.Log(WARN, "is not primative")
|
||||
}
|
||||
})
|
||||
newgrid.NewButton("MakeRedomod()", func() {
|
||||
rs.MakeRedomod()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -222,7 +243,6 @@ func (rs *RepoStatus) drawGitCommands() {
|
|||
newgrid.Pad()
|
||||
}
|
||||
|
||||
|
||||
func (rs *RepoStatus) SetVersion(a, b, c string, reason string) {
|
||||
rs.major.SetText(a)
|
||||
rs.minor.SetText(b)
|
||||
|
@ -255,9 +275,10 @@ func (rs *RepoStatus) setTag() bool {
|
|||
}
|
||||
if newa > olda {
|
||||
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
|
||||
rs.minor.SetText("0")
|
||||
rs.revision.SetText("0")
|
||||
newver := strconv.Itoa(newa) + ".0.0"
|
||||
rs.newversion.SetLabel(newver)
|
||||
rs.minor.SetText("")
|
||||
rs.revision.SetText("")
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -271,8 +292,9 @@ func (rs *RepoStatus) setTag() bool {
|
|||
|
||||
if newb > oldb {
|
||||
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
|
||||
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + ".0"
|
||||
rs.newversion.SetLabel(newver)
|
||||
rs.revision.SetText("")
|
||||
rs.revision.SetText("0")
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
8
git.go
8
git.go
|
@ -95,6 +95,7 @@ func (rs *RepoStatus) CheckDirty() bool {
|
|||
err, b, out := RunCmd(path, cmd)
|
||||
if err != nil {
|
||||
log.Warn("CheckDirty() b =", b)
|
||||
log.Warn("CheckDirty() cmd =", cmd)
|
||||
log.Warn("CheckDirty() path =", path)
|
||||
log.Warn("CheckDirty() out =", out)
|
||||
log.Warn("CheckDirty() err =", err)
|
||||
|
@ -108,7 +109,12 @@ func (rs *RepoStatus) CheckDirty() bool {
|
|||
rs.dirtyLabel.SetValue("no")
|
||||
return false
|
||||
}
|
||||
log.Log(INFO, "CheckDirty() true", rs.realPath.String())
|
||||
log.Log(WARN, "CheckDirty() true", rs.realPath.String())
|
||||
log.Log(WARN, "CheckDirty() cmd =", cmd)
|
||||
log.Log(WARN, "CheckDirty() b =", b)
|
||||
log.Log(WARN, "CheckDirty() path =", path)
|
||||
log.Log(WARN, "CheckDirty() out =", out)
|
||||
log.Log(WARN, "CheckDirty() err =", err)
|
||||
rs.dirtyLabel.SetValue("dirty")
|
||||
return true
|
||||
|
||||
|
|
71
gitConfig.go
71
gitConfig.go
|
@ -185,9 +185,11 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// readGoMod reads and parses the go.sum file (TODO: do the go.mod file)
|
||||
func (rs *RepoStatus) ReadGoMod() bool {
|
||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
||||
// this checks to see if the repo is truly not dependent on _anything_ else
|
||||
// like spew or lib/widget
|
||||
func (rs *RepoStatus) CheckPrimativeGoMod() bool {
|
||||
log.Log(WARN, "CheckPrimativeGoMod()", rs.realPath.String())
|
||||
tmp := filepath.Join(rs.realPath.String(), "go.mod")
|
||||
gomod, err := os.Open(tmp)
|
||||
if err != nil {
|
||||
log.Log(WARN, "missing go.mod", rs.realPath.String())
|
||||
|
@ -196,7 +198,32 @@ func (rs *RepoStatus) ReadGoMod() bool {
|
|||
}
|
||||
defer gomod.Close()
|
||||
|
||||
tmp = filepath.Join(rs.realPath.String(), "go.sum")
|
||||
scanner := bufio.NewScanner(gomod)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
|
||||
parts := strings.Split(line, " ")
|
||||
log.Log(WARN, " gomod:", parts)
|
||||
if len(parts) >= 1 {
|
||||
log.Log(WARN, " gomod: part[0] =", parts[0])
|
||||
if parts[0] == "require" {
|
||||
log.Log(WARN, " should return false here")
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// readGoMod reads and parses the go.sum file (TODO: do the go.mod file)
|
||||
func (rs *RepoStatus) ReadGoMod() bool {
|
||||
if rs.CheckPrimativeGoMod() {
|
||||
log.Info("PRIMATIVE repo:", rs.String())
|
||||
return true
|
||||
}
|
||||
|
||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
||||
gosum, err := os.Open(tmp)
|
||||
if err != nil {
|
||||
log.Log(WARN, "missing go.sum", rs.realPath.String())
|
||||
|
@ -301,8 +328,8 @@ func (rs *RepoStatus) CheckGoSum() bool {
|
|||
username := newrs.userWorkingName.String()
|
||||
userhash, _ := newrs.gitConfig.hashes[username]
|
||||
userversion, _ := newrs.gitConfig.versions[userhash]
|
||||
log.Log(WARN, " username :" + username, userhash)
|
||||
log.Log(WARN, " username :" + username, userversion)
|
||||
log.Log(WARN, " username :"+username, userhash)
|
||||
log.Log(WARN, " username :"+username, userversion)
|
||||
if version == userversion {
|
||||
log.Log(WARN, " USER VERSIONS MATCH", version, userversion)
|
||||
} else {
|
||||
|
@ -311,12 +338,44 @@ func (rs *RepoStatus) CheckGoSum() bool {
|
|||
}
|
||||
} else {
|
||||
log.Log(WARN, " NOT FOUND", depname)
|
||||
log.Log(WARN, " go get -v", depname)
|
||||
rs.RunCmd([]string{"go", "get", "-v", depname})
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) MakeRedomod() {
|
||||
var err error
|
||||
var b bool
|
||||
var output string
|
||||
var worked bool = true
|
||||
|
||||
os.Unsetenv("GO111MODULE")
|
||||
path := rs.realPath.String()
|
||||
err, b, output = RunCmd(path, []string{"rm", "-f", "go.mod", "go.sum"})
|
||||
if err != nil {
|
||||
worked = false
|
||||
log.Log(WARN, "rm failed", err, b, output)
|
||||
}
|
||||
err, b, output = RunCmd(path, []string{"go", "mod", "init"})
|
||||
if err != nil {
|
||||
worked = false
|
||||
log.Log(WARN, "go mod init failed", err, b, output)
|
||||
}
|
||||
err, b, output = RunCmd(path, []string{"go", "mod", "tidy"})
|
||||
if err != nil {
|
||||
worked = false
|
||||
log.Log(WARN, "go mod tidy failed", err, b, output)
|
||||
}
|
||||
if worked {
|
||||
log.Log(WARN, "MakeRedomod() worked", path)
|
||||
} else {
|
||||
log.Log(WARN, "MakeRedomod() failed", path)
|
||||
}
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) processBranch(branch string) {
|
||||
fullpath := rs.realPath.String()
|
||||
log.Log(WARN, " ", branch)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module go.wit.com/lib/gui/repostatus
|
|||
go 1.21.4
|
||||
|
||||
require (
|
||||
go.wit.com/gui v0.12.20
|
||||
go.wit.com/gui v0.13.11
|
||||
go.wit.com/lib/gadgets v0.12.16
|
||||
go.wit.com/log v0.5.6
|
||||
go.wit.com/widget v1.1.6
|
||||
|
|
4
go.sum
4
go.sum
|
@ -4,8 +4,8 @@ go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26
|
|||
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
||||
go.wit.com/gui v0.12.20 h1:mIc2DKGcpQjZdgtAj5qzkBrBDiteWfIaEpLyMnIBkh8=
|
||||
go.wit.com/gui v0.12.20/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||
go.wit.com/gui v0.13.11 h1:d74Ko/XFZYR25P/AZfCQaVO2CuGh1BSjdUp1wjktdDg=
|
||||
go.wit.com/gui v0.13.11/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||
go.wit.com/lib/gadgets v0.12.16 h1:xHz8zZiTe8xiGvfWs3s9drYUbePTT/Te58u7WXHjx0s=
|
||||
go.wit.com/lib/gadgets v0.12.16/go.mod h1:9779QoRZlk+G3/MCcX4Io1eH3HTLImE0AXdAMMdw+0U=
|
||||
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
|
||||
|
|
22
unix.go
22
unix.go
|
@ -10,6 +10,7 @@ import (
|
|||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -115,6 +116,17 @@ func splitVersion(version string) (a, b, c string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) RunCmd(parts []string) (error, string) {
|
||||
path := rs.realPath.String()
|
||||
err, _, output := RunCmd(path, parts)
|
||||
if err != nil {
|
||||
log.Log(WARN, "cmd:", parts)
|
||||
log.Log(WARN, "ouptput:", output)
|
||||
log.Log(WARN, "failed with error:", err)
|
||||
}
|
||||
return err, output
|
||||
}
|
||||
|
||||
// temp hack. fix this
|
||||
func runCmd(path string, parts []string) (error, bool, string) {
|
||||
return RunCmd(path, parts)
|
||||
|
@ -162,6 +174,16 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) {
|
|||
log.Warn("cmd exited with error", err)
|
||||
// panic("fucknuts")
|
||||
return err, false, string(output)
|
||||
|
||||
// The command failed (non-zero exit status)
|
||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
// Assert that it is an exec.ExitError and get the exit code
|
||||
if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
|
||||
log.Warn("Exit Status: %d\n", status.ExitStatus())
|
||||
}
|
||||
} else {
|
||||
log.Warn("cmd.Run() failed with %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
tmp := string(output)
|
||||
|
|
Loading…
Reference in New Issue