changes for the autotypist

go mod automation testing
    read tags

    Signed-off-by: Jeff Carr <jcarr@wit.com>

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-20 21:18:03 -06:00
parent e3cc044efc
commit 7a05ee53ab
5 changed files with 57 additions and 41 deletions

70
draw.go
View File

@ -75,7 +75,6 @@ func (rs *RepoStatus) drawGitBranches() {
func (rs *RepoStatus) drawGitStatus() {
rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has")
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
// newgrid.SetNext(1,1)
newgrid.Margin()
newgrid.Pad()
@ -84,6 +83,16 @@ func (rs *RepoStatus) drawGitStatus() {
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version")
rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags")
// git for-each-ref --sort=taggerdate --format '%(tag) ,,,_,,, %(subject)' refs/tags
var cmd []string
cmd = append(cmd, "git", "for-each-ref", "--sort=taggerdate", "--format", "%(tag) %(subject)", "refs/tags")
_, _, output := RunCmd("/home/jcarr/go/src/"+rs.repopath, cmd)
log.Info(output)
for _, line := range strings.Split(output, "\n") {
rs.tagsDrop.AddText(line)
}
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
@ -102,23 +111,7 @@ func (rs *RepoStatus) drawGitCommands() {
rs.Update()
})
label := "merge " + rs.masterDrop.String() + " to devel"
rs.develMerge = newgrid.NewButton(label, func() {
rs.Disable()
master := rs.masterDrop.String()
rs.checkoutBranch("master", master)
if rs.getCurrentBranchName() != master {
log.Warn("something went wrong switching to the master branch. full stop!")
return
}
if !rs.runGitCommands() {
log.Warn("SOMETHING WENT WRONG")
return
}
rs.Update()
rs.Enable()
log.Warn("THINGS SEEM OK")
})
newgrid.NewLabel("tmp")
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
rs.major.Custom = func() {
@ -136,7 +129,7 @@ func (rs *RepoStatus) drawGitCommands() {
rs.generateCmd()
}
newgrid.NewLabel("new tag version")
rs.newversion = newgrid.NewLabel("3.1.4")
rs.newversion = newgrid.NewLabel("0.0.1")
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
rs.versionMessage.Custom = func() {
@ -144,6 +137,24 @@ func (rs *RepoStatus) drawGitCommands() {
}
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
label := "merge " + rs.masterDrop.String() + " to devel"
rs.develMerge = newgrid.NewButton(label, func() {
rs.Disable()
master := rs.masterDrop.String()
rs.checkoutBranch("master", master)
if rs.getCurrentBranchName() != master {
log.Warn("something went wrong switching to the master branch. full stop!")
return
}
if !rs.runGitCommands() {
log.Warn("SOMETHING WENT WRONG")
return
}
rs.Update()
rs.Enable()
log.Warn("THINGS SEEM OK")
})
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
if !rs.generateCmd() {
log.Warn("something is wrong. fix the errors first")
@ -179,12 +190,12 @@ func (rs *RepoStatus) setTag() bool {
newver := strconv.Itoa(newa)
if newa < olda {
log.Warn("new version bad", newver, "vs old version", lasttag, "newa =", newa, "olda =", olda)
rs.newversion.SetText("bad")
rs.newversion.SetLabel("bad")
return false
}
if newa > olda {
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.SetText(newver)
rs.newversion.SetLabel(newver)
rs.minor.SetText("")
rs.revision.SetText("")
return true
@ -194,13 +205,13 @@ func (rs *RepoStatus) setTag() bool {
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb)
if newb < oldb {
log.Warn("new version bad", newver, "vs old version", lasttag, "newb =", newb, "oldb =", oldb)
rs.newversion.SetText("bad")
rs.newversion.SetLabel("bad")
return false
}
if newb > oldb {
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.SetText(newver)
rs.newversion.SetLabel(newver)
rs.revision.SetText("")
return true
}
@ -209,11 +220,11 @@ func (rs *RepoStatus) setTag() bool {
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + "." + strconv.Itoa(newc)
if newc <= oldc {
log.Warn("new version bad", newver, "vs old version", lasttag)
rs.newversion.SetText("bad")
rs.newversion.SetLabel("bad")
return false
}
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.SetText(newver)
rs.newversion.SetLabel(newver)
return true
}
@ -253,8 +264,8 @@ func (rs *RepoStatus) recommend() {
log.Warn("merge or squash?")
rs.EnableMergeDevel()
rs.setMergeUserCommands()
label := "merge " + rs.GetUserBranchName() + " into " + rs.GetDevelBranchName()
rs.develMerge.SetText(label)
label := "merge user into " + rs.GetDevelBranchName()
rs.develMerge.SetLabel(label)
return
}
log.Warn("Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String())
@ -262,8 +273,8 @@ func (rs *RepoStatus) recommend() {
log.Warn("master does not equal devel. merge devel into master")
rs.EnableMergeDevel()
rs.setMergeDevelCommands()
label := "merge " + rs.GetDevelBranchName() + " into " + rs.GetMasterBranchName()
rs.develMerge.SetText(label)
label := "merge devel into " + rs.GetMasterBranchName()
rs.develMerge.SetLabel(label)
return
}
rs.getLastTagVersion()
@ -272,7 +283,6 @@ func (rs *RepoStatus) recommend() {
rs.incrementVersion()
rs.EnableSelectTag()
rs.setTag()
rs.versionMessage.SetText("TODO: set globally")
return
}
log.Warn("Is repo pushed upstream? git.wit.org or github?")

7
git.go
View File

@ -243,14 +243,17 @@ func (rs *RepoStatus) GetStatus() string {
return "merge to devel"
}
if rs.userBranchVersion.String() != rs.masterBranchVersion.String() {
return "release"
return "ready to release"
}
if rs.lasttag.String() != rs.masterBranchVersion.String() {
return "ready to tag version"
}
if rs.CheckBranches() {
log.Warn("Branches are Perfect")
return "PERFECT"
}
log.Warn("Branches are not Perfect")
log.Warn(rs.GetPath(), "Branches are not Perfect")
return "unknown branches"
}

6
go.mod
View File

@ -3,9 +3,9 @@ module go.wit.com/lib/gui/repostatus
go 1.21.4
require (
go.wit.com/gui v0.12.18
go.wit.com/lib/gadgets v0.12.12
go.wit.com/log v0.5.5
go.wit.com/gui v0.12.19
go.wit.com/lib/gadgets v0.12.14
go.wit.com/log v0.5.6
go.wit.com/widget v1.1.6
)

12
go.sum
View File

@ -4,11 +4,11 @@ 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.18 h1:gFVDaJFz/Su8JgUd9Oxnb3t+FS+bzy5WJSvGoKVGYZU=
go.wit.com/gui v0.12.18/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
go.wit.com/lib/gadgets v0.12.12 h1:3UFxKIOibaztREXgsLpMhVzG3w0gT3V98QzbWg2EPoc=
go.wit.com/lib/gadgets v0.12.12/go.mod h1:1bT2DhJkwP7zJJydhiAnchlh+WJU4BWdhkYnX6mvQME=
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
go.wit.com/gui v0.12.19 h1:OEnsnZnec7Q2jZVjwl413V0wuVAAB4r2mGTY0IouBuw=
go.wit.com/gui v0.12.19/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
go.wit.com/lib/gadgets v0.12.14 h1:Osh7D8TKJiU5M6tXqERGQwTUt+C5IJ0senkmUAirSek=
go.wit.com/lib/gadgets v0.12.14/go.mod h1:Fxc7F8hGskpkWVAsXKhs4ilqUlAnikVXj4yzumtTYa0=
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY=
go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=

View File

@ -116,6 +116,9 @@ func (rs *RepoStatus) EnableSelectTag() {
// disable adding a tag message
rs.versionMessage.Enable()
rs.versionMessage.SetText("")
rs.develMerge.SetLabel("ready to release")
// force there to be a commit message
rs.releaseVersion.Disable()