2024-01-09 15:34:53 -06:00
|
|
|
package repostatus
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
import (
|
2024-01-10 00:15:27 -06:00
|
|
|
"strconv"
|
2024-01-10 18:18:01 -06:00
|
|
|
"strings"
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/log"
|
2024-01-18 05:01:54 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-09 15:34:53 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// creates the actual widgets.
|
|
|
|
// it's assumed you are always passing in a box
|
2024-01-23 22:47:39 -06:00
|
|
|
func (rs *RepoStatus) draw() {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// display the status of the git repository
|
2024-01-23 22:47:39 -06:00
|
|
|
rs.drawGitStatus()
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// display the git branches and options
|
|
|
|
rs.drawGitBranches()
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// show standard git commit and merge controls
|
|
|
|
rs.drawGitCommands()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) drawGitBranches() {
|
|
|
|
rs.gitBranchesGroup = rs.window.Box().NewGroup("branches")
|
|
|
|
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 2, 2)
|
|
|
|
|
2024-01-23 10:52:17 -06:00
|
|
|
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
|
|
|
|
|
|
|
|
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
|
|
|
|
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
|
|
|
|
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
|
|
|
|
|
|
|
|
rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch")
|
|
|
|
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version")
|
|
|
|
|
2024-01-23 15:20:54 -06:00
|
|
|
rs.showBranchesButton = newgrid.NewButton("getBranches()", func() {
|
2024-01-11 15:56:50 -06:00
|
|
|
all := rs.getBranches()
|
|
|
|
i := len(all)
|
2024-01-23 15:20:54 -06:00
|
|
|
log.Log(WARN, "branch count =", i)
|
2024-01-11 15:56:50 -06:00
|
|
|
})
|
2024-01-11 23:24:09 -06:00
|
|
|
|
2024-01-23 15:20:54 -06:00
|
|
|
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
|
2024-01-13 20:30:33 -06:00
|
|
|
if rs.CheckBranches() {
|
2024-01-23 15:20:54 -06:00
|
|
|
log.Log(WARN, "Branches are perfect")
|
2024-01-11 23:24:09 -06:00
|
|
|
} else {
|
2024-01-23 15:20:54 -06:00
|
|
|
log.Log(WARN, "Branches are not perfect")
|
2024-01-23 10:52:17 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
newgrid.NewButton("show .git/config", func() {
|
|
|
|
if rs.gitConfig == nil {
|
2024-01-23 15:39:53 -06:00
|
|
|
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
|
2024-01-23 10:52:17 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Log(WARN, ".git/config:", rs.realPath.String())
|
|
|
|
|
|
|
|
// The info:
|
|
|
|
for name, remote := range rs.gitConfig.remotes {
|
2024-01-23 15:20:54 -06:00
|
|
|
log.Log(WARN, " ", name, "url:", remote.url)
|
2024-01-23 10:52:17 -06:00
|
|
|
}
|
|
|
|
for name, branch := range rs.gitConfig.branches {
|
|
|
|
log.Log(WARN, " ", name, "remote:", branch.remote, "merge", branch.merge)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-24 16:24:58 -06:00
|
|
|
newgrid.NewButton("CheckDirty()", func() {
|
|
|
|
if rs.CheckDirty() {
|
|
|
|
log.Log(WARN, "is dirty")
|
|
|
|
} else {
|
|
|
|
log.Log(WARN, "is not dirty")
|
|
|
|
}
|
|
|
|
})
|
2024-01-26 09:34:13 -06:00
|
|
|
|
|
|
|
newgrid.NewButton("CheckSafeGoSumRemake()", func() {
|
|
|
|
if ok, bad := rs.CheckSafeGoSumRemake(); ok {
|
|
|
|
log.Log(WARN, "CheckSafeGoSumRemake() is safe to redo")
|
|
|
|
} else {
|
|
|
|
log.Log(WARN, "CheckSafeGoSumRemake() is not safe. problems:", bad)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-24 16:24:58 -06:00
|
|
|
newgrid.NewButton("CheckGoSum()", func() {
|
2024-01-25 01:30:01 -06:00
|
|
|
if ok, missing := rs.CheckGoSum(); ok {
|
2024-01-24 16:24:58 -06:00
|
|
|
log.Log(WARN, "CheckGoSum() is ok")
|
|
|
|
} else {
|
2024-01-25 01:30:01 -06:00
|
|
|
log.Log(WARN, "CheckGoSum() is not ok. missing:", missing)
|
2024-01-24 16:24:58 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
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()
|
2024-01-11 15:56:50 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-01-23 22:47:39 -06:00
|
|
|
func (rs *RepoStatus) drawGitStatus() {
|
2024-01-11 15:56:50 -06:00
|
|
|
rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has")
|
|
|
|
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
|
|
|
newgrid.Margin()
|
|
|
|
newgrid.Pad()
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
2024-01-23 22:47:39 -06:00
|
|
|
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
|
|
|
|
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
|
2024-01-23 10:52:17 -06:00
|
|
|
rs.realPath.Hide()
|
|
|
|
rs.mainWorkingName = gadgets.NewOneLiner(newgrid, "main working branch")
|
|
|
|
rs.mainWorkingName.SetValue("???")
|
|
|
|
rs.develWorkingName = gadgets.NewOneLiner(newgrid, "devel working branch")
|
|
|
|
rs.develWorkingName.SetValue("devel")
|
|
|
|
rs.userWorkingName = gadgets.NewOneLiner(newgrid, "user working branch")
|
|
|
|
rs.userWorkingName.SetValue("uid")
|
|
|
|
rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "all releases")
|
2024-01-20 21:18:03 -06:00
|
|
|
|
|
|
|
// 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")
|
2024-01-23 15:20:54 -06:00
|
|
|
_, _, output := RunCmd(rs.realPath.String(), cmd)
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, output)
|
2024-01-20 21:18:03 -06:00
|
|
|
for _, line := range strings.Split(output, "\n") {
|
|
|
|
rs.tagsDrop.AddText(line)
|
|
|
|
}
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
|
2024-01-23 22:47:39 -06:00
|
|
|
rs.readOnly = gadgets.NewOneLiner(newgrid, "read only")
|
2024-01-26 02:02:56 -06:00
|
|
|
rs.goSumStatus = gadgets.NewOneLiner(newgrid, "go mod status")
|
2024-01-11 15:56:50 -06:00
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.speed = gadgets.NewOneLiner(newgrid, "refresh speed =")
|
|
|
|
rs.speedActual = gadgets.NewOneLiner(newgrid, "speed actual =")
|
2024-01-11 15:56:50 -06:00
|
|
|
}
|
|
|
|
|
2024-01-26 02:02:56 -06:00
|
|
|
func (rs *RepoStatus) SetGoSumStatus(s string) {
|
|
|
|
rs.goSumStatus.SetText(s)
|
|
|
|
}
|
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
func (rs *RepoStatus) drawGitCommands() {
|
|
|
|
rs.gitCommandsGroup = rs.window.Box().NewGroup("git commands")
|
|
|
|
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 2, 2)
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
newgrid.NewButton("update", func() {
|
2024-01-09 15:34:53 -06:00
|
|
|
rs.Update()
|
|
|
|
})
|
|
|
|
|
2024-01-20 21:38:12 -06:00
|
|
|
newgrid.NewButton("git pull", func() {
|
|
|
|
var cmd []string
|
|
|
|
cmd = append(cmd, "git", "pull")
|
2024-01-23 15:20:54 -06:00
|
|
|
err, b, output := RunCmd(rs.realPath.String(), cmd)
|
2024-01-20 21:38:12 -06:00
|
|
|
log.Warn("Did git pull here", err, b, output)
|
2024-01-20 21:33:28 -06:00
|
|
|
})
|
2024-01-10 18:18:01 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.major.Custom = func() {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.setTag()
|
|
|
|
rs.generateCmd()
|
|
|
|
}
|
|
|
|
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.minor.Custom = func() {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.setTag()
|
|
|
|
rs.generateCmd()
|
|
|
|
}
|
|
|
|
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.revision.Custom = func() {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.setTag()
|
|
|
|
rs.generateCmd()
|
|
|
|
}
|
|
|
|
newgrid.NewLabel("new tag version")
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion = newgrid.NewLabel("0.0.1")
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.versionMessage.Custom = func() {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.generateCmd()
|
|
|
|
}
|
|
|
|
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
|
|
|
|
|
2024-01-25 01:30:01 -06:00
|
|
|
label := "merge " + rs.mainWorkingName.String() + " to devel"
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.develMerge = newgrid.NewButton(label, func() {
|
|
|
|
rs.Disable()
|
2024-01-25 01:30:01 -06:00
|
|
|
master := rs.mainWorkingName.String()
|
|
|
|
log.Warn("develMerge() checking out master branch", master)
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.checkoutBranch("master", master)
|
|
|
|
if rs.getCurrentBranchName() != master {
|
|
|
|
log.Warn("something went wrong switching to the master branch. full stop!")
|
|
|
|
return
|
|
|
|
}
|
2024-01-25 01:30:01 -06:00
|
|
|
log.Warn("develMerge() running runGitCommands()")
|
|
|
|
if !rs.runGitCommands(true) {
|
2024-01-20 21:18:03 -06:00
|
|
|
log.Warn("SOMETHING WENT WRONG")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
rs.Update()
|
|
|
|
rs.Enable()
|
|
|
|
log.Warn("THINGS SEEM OK")
|
|
|
|
})
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
|
2024-01-25 01:30:01 -06:00
|
|
|
rs.Disable()
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.generateCmd() {
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Warn("something is wrong. fix the errors first")
|
|
|
|
return
|
|
|
|
}
|
2024-01-14 15:51:25 -06:00
|
|
|
rs.releaseVersion.Disable()
|
2024-01-25 01:30:01 -06:00
|
|
|
log.Warn("MAKING A RELEASE AND VERSION")
|
|
|
|
if !rs.runGitCommands(true) {
|
2024-01-11 15:56:50 -06:00
|
|
|
log.Warn("SOMETHING WENT WRONG")
|
|
|
|
}
|
2024-01-11 23:24:09 -06:00
|
|
|
rs.Update()
|
2024-01-25 01:30:01 -06:00
|
|
|
rs.Enable()
|
2024-01-11 23:24:09 -06:00
|
|
|
log.Warn("THINGS SEEM OK")
|
2024-01-09 19:22:16 -06:00
|
|
|
})
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
newgrid.Margin()
|
|
|
|
newgrid.Pad()
|
|
|
|
}
|
|
|
|
|
2024-01-26 11:53:22 -06:00
|
|
|
var releaseRevision string = ""
|
|
|
|
// over ride the computation of this if a release is being created
|
|
|
|
func (rs *RepoStatus) setRevision(c string) {
|
|
|
|
if releaseRevision == "" {
|
|
|
|
rs.revision.SetText(c)
|
|
|
|
}
|
|
|
|
rs.revision.SetText(releaseRevision)
|
|
|
|
}
|
|
|
|
|
2024-01-24 01:57:01 -06:00
|
|
|
func (rs *RepoStatus) SetVersion(a, b, c string, reason string) {
|
2024-01-24 02:22:32 -06:00
|
|
|
rs.major.SetText(a)
|
|
|
|
rs.minor.SetText(b)
|
2024-01-26 11:53:22 -06:00
|
|
|
releaseRevision = c
|
|
|
|
rs.setRevision(c)
|
2024-01-24 01:57:01 -06:00
|
|
|
|
2024-01-24 02:22:32 -06:00
|
|
|
rs.versionMessage.SetLabel(reason)
|
|
|
|
rs.versionMessage.SetText(reason)
|
|
|
|
// rs.versionMessage.SetValue(reason)
|
2024-01-24 01:57:01 -06:00
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) setTag() bool {
|
2024-01-17 03:59:13 -06:00
|
|
|
lasttag := rs.lasttag.String()
|
2024-01-10 18:18:01 -06:00
|
|
|
var major, minor, revision string
|
|
|
|
major, minor, revision = splitVersion(lasttag)
|
|
|
|
|
|
|
|
olda, _ := strconv.Atoi(major)
|
|
|
|
oldb, _ := strconv.Atoi(minor)
|
|
|
|
oldc, _ := strconv.Atoi(revision)
|
|
|
|
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "current version here", lasttag)
|
|
|
|
log.Log(INFO, "current release a,b,c =", major, minor, revision)
|
2024-01-10 18:18:01 -06:00
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
newa, _ := strconv.Atoi(rs.major.String())
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
newver := strconv.Itoa(newa)
|
|
|
|
if newa < olda {
|
2024-01-11 23:24:09 -06:00
|
|
|
log.Warn("new version bad", newver, "vs old version", lasttag, "newa =", newa, "olda =", olda)
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel("bad")
|
2024-01-10 18:18:01 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if newa > olda {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
|
2024-01-24 16:24:58 -06:00
|
|
|
rs.minor.SetText("0")
|
2024-01-26 11:53:22 -06:00
|
|
|
rs.setRevision("0")
|
2024-01-24 16:24:58 -06:00
|
|
|
newver := strconv.Itoa(newa) + ".0.0"
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel(newver)
|
2024-01-10 18:18:01 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
newb, _ := strconv.Atoi(rs.minor.String())
|
2024-01-10 18:18:01 -06:00
|
|
|
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb)
|
|
|
|
if newb < oldb {
|
2024-01-11 23:24:09 -06:00
|
|
|
log.Warn("new version bad", newver, "vs old version", lasttag, "newb =", newb, "oldb =", oldb)
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel("bad")
|
2024-01-10 18:18:01 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if newb > oldb {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
|
2024-01-24 16:24:58 -06:00
|
|
|
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + ".0"
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel(newver)
|
2024-01-26 11:53:22 -06:00
|
|
|
rs.setRevision("0")
|
2024-01-10 18:18:01 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
newc, _ := strconv.Atoi(rs.revision.String())
|
2024-01-10 18:18:01 -06:00
|
|
|
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + "." + strconv.Itoa(newc)
|
|
|
|
if newc <= oldc {
|
|
|
|
log.Warn("new version bad", newver, "vs old version", lasttag)
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel("bad")
|
2024-01-10 18:18:01 -06:00
|
|
|
return false
|
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
|
2024-01-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel(newver)
|
2024-01-10 18:18:01 -06:00
|
|
|
return true
|
2024-01-09 15:34:53 -06:00
|
|
|
}
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-10 00:43:15 -06:00
|
|
|
func (rs *RepoStatus) incrementVersion() {
|
2024-01-17 03:59:13 -06:00
|
|
|
lasttag := rs.lasttag.String()
|
2024-01-10 00:43:15 -06:00
|
|
|
var major, minor, revision string
|
|
|
|
major, minor, revision = splitVersion(lasttag)
|
|
|
|
log.Warn("Should release version here", lasttag)
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Should release a,b,c", major, minor, revision)
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
a, _ := strconv.Atoi(major)
|
|
|
|
b, _ := strconv.Atoi(minor)
|
|
|
|
c, _ := strconv.Atoi(revision)
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.major.AddText(widget.GetString(a))
|
|
|
|
rs.major.AddText(widget.GetString(a + 1))
|
|
|
|
rs.major.SetText(widget.GetString(a))
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.minor.AddText(widget.GetString(b))
|
|
|
|
rs.minor.AddText(widget.GetString(b + 1))
|
|
|
|
rs.minor.SetText(widget.GetString(b))
|
2024-01-10 00:15:27 -06:00
|
|
|
|
2024-01-10 00:43:15 -06:00
|
|
|
// rs.c := strconv.Atoi(revision)
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.revision.AddText(widget.GetString(c + 1))
|
|
|
|
rs.revision.AddText(widget.GetString(c + 2))
|
2024-01-26 11:53:22 -06:00
|
|
|
rs.setRevision(widget.GetString(c + 1))
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) recommend() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Is repo dirty?", rs.dirtyLabel.String())
|
|
|
|
log.Log(INFO, "list the known tags")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.DisableEverything()
|
|
|
|
rs.populateTags()
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Does devel == user?", rs.develBranchVersion.String(), rs.userBranchVersion.String())
|
2024-01-17 03:59:13 -06:00
|
|
|
if rs.develBranchVersion.String() != rs.userBranchVersion.String() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "devel does not equal user")
|
|
|
|
log.Log(INFO, "merge or squash?")
|
2024-01-13 22:08:49 -06:00
|
|
|
rs.EnableMergeDevel()
|
|
|
|
rs.setMergeUserCommands()
|
2024-01-20 21:18:03 -06:00
|
|
|
label := "merge user into " + rs.GetDevelBranchName()
|
|
|
|
rs.develMerge.SetLabel(label)
|
2024-01-10 18:18:01 -06:00
|
|
|
return
|
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String())
|
2024-01-17 03:59:13 -06:00
|
|
|
if rs.masterBranchVersion.String() != rs.develBranchVersion.String() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "master does not equal devel. merge devel into master")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.EnableMergeDevel()
|
2024-01-11 15:56:50 -06:00
|
|
|
rs.setMergeDevelCommands()
|
2024-01-20 21:18:03 -06:00
|
|
|
label := "merge devel into " + rs.GetMasterBranchName()
|
|
|
|
rs.develMerge.SetLabel(label)
|
2024-01-10 18:18:01 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
rs.getLastTagVersion()
|
2024-01-17 03:59:13 -06:00
|
|
|
if rs.lasttag.String() != rs.masterBranchVersion.String() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "master does not equal last tag")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.incrementVersion()
|
|
|
|
rs.EnableSelectTag()
|
|
|
|
rs.setTag()
|
|
|
|
return
|
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Is repo pushed upstream? git.wit.org or github?")
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) generateCmd() bool {
|
|
|
|
// the length of 24 is arbitrary, but should be short
|
|
|
|
// they should be things like perhaps, major release names
|
|
|
|
// or something the users might see.
|
|
|
|
// aka: "Topsy", "Picasso", "Buzz", etc
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.setTag() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "tag sucked. fix your tag version")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.versionMessage.SetLabel("tag message (bad version)")
|
|
|
|
rs.releaseVersion.Disable()
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "tag is valid!!!!")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.setGitCommands()
|
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
if rs.versionMessage.String() == "" {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "tag message is empty!!!!")
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.releaseVersion.Disable()
|
|
|
|
return false
|
|
|
|
}
|
2024-01-17 03:59:13 -06:00
|
|
|
if len(rs.versionMessage.String()) > 24 {
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.versionMessage.SetLabel("tag message (too long)")
|
|
|
|
} else {
|
|
|
|
rs.versionMessage.SetLabel("tag message")
|
|
|
|
}
|
|
|
|
rs.releaseVersion.Enable()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:30:01 -06:00
|
|
|
func (rs *RepoStatus) runGitCommands(verbose bool) bool {
|
2024-01-11 15:56:50 -06:00
|
|
|
for _, line := range rs.versionCmds {
|
|
|
|
s := strings.Join(line, " ")
|
2024-01-25 01:30:01 -06:00
|
|
|
if verbose {
|
|
|
|
log.Log(WARN, "RUNNING:", s)
|
|
|
|
}
|
2024-01-14 15:43:47 -06:00
|
|
|
rs.develMerge.SetText(s)
|
2024-01-23 15:20:54 -06:00
|
|
|
err, b, output := runCmd(rs.realPath.String(), line)
|
2024-01-11 15:56:50 -06:00
|
|
|
if err != nil {
|
|
|
|
log.Warn("ABEND EXECUTION")
|
|
|
|
log.Warn("error =", err)
|
|
|
|
log.Warn("output =", output)
|
|
|
|
return false
|
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Returned with b =", b)
|
|
|
|
log.Log(INFO, "output was =", output)
|
|
|
|
log.Log(INFO, "RUN DONE")
|
2024-01-11 15:56:50 -06:00
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
func (rs *RepoStatus) setGitCommands() {
|
|
|
|
var line1, line2, line3 []string
|
|
|
|
var all [][]string
|
|
|
|
|
2024-01-17 03:59:13 -06:00
|
|
|
newTag := rs.newversion.String()
|
2024-01-18 00:57:43 -06:00
|
|
|
line1 = append(line1, "git", "tag", "v"+newTag, "-m", rs.versionMessage.String())
|
2024-01-10 18:18:01 -06:00
|
|
|
all = append(all, line1)
|
|
|
|
line2 = append(line2, "git", "push", "--tags")
|
|
|
|
all = append(all, line2)
|
|
|
|
line3 = append(line3, "git", "push", "--prune", "--tags")
|
|
|
|
all = append(all, line3)
|
|
|
|
|
|
|
|
rs.versionCmds = all
|
|
|
|
|
|
|
|
var tmp []string
|
|
|
|
// convert to displayable to the user text
|
|
|
|
for _, line := range all {
|
|
|
|
s := strings.Join(line, " ")
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "s =", s)
|
2024-01-10 18:18:01 -06:00
|
|
|
tmp = append(tmp, s)
|
|
|
|
}
|
|
|
|
|
2024-01-19 12:36:52 -06:00
|
|
|
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
2024-01-11 15:56:50 -06:00
|
|
|
|
|
|
|
func (rs *RepoStatus) setMergeDevelCommands() {
|
2024-01-13 22:08:49 -06:00
|
|
|
var line1, line2, line3 []string
|
2024-01-11 15:56:50 -06:00
|
|
|
var all [][]string
|
|
|
|
|
2024-01-19 18:25:37 -06:00
|
|
|
master := rs.GetMasterBranchName()
|
|
|
|
devel := rs.GetDevelBranchName()
|
2024-01-13 22:08:49 -06:00
|
|
|
|
|
|
|
line1 = append(line1, "git", "checkout", master)
|
2024-01-11 15:56:50 -06:00
|
|
|
all = append(all, line1)
|
2024-01-13 22:08:49 -06:00
|
|
|
line2 = append(line2, "git", "merge", devel)
|
2024-01-11 15:56:50 -06:00
|
|
|
all = append(all, line2)
|
2024-01-13 22:08:49 -06:00
|
|
|
line3 = append(line3, "git", "push")
|
|
|
|
all = append(all, line3)
|
|
|
|
|
|
|
|
rs.versionCmds = all
|
|
|
|
|
|
|
|
var tmp []string
|
|
|
|
// convert to displayable to the user text
|
|
|
|
for _, line := range all {
|
|
|
|
s := strings.Join(line, " ")
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "s =", s)
|
2024-01-13 22:08:49 -06:00
|
|
|
tmp = append(tmp, s)
|
|
|
|
}
|
|
|
|
|
2024-01-19 12:36:52 -06:00
|
|
|
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
|
2024-01-13 22:08:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) setMergeUserCommands() {
|
|
|
|
var line1, line2, line3 []string
|
|
|
|
var all [][]string
|
|
|
|
|
2024-01-19 18:25:37 -06:00
|
|
|
devel := rs.GetDevelBranchName()
|
2024-01-25 01:30:01 -06:00
|
|
|
user := rs.userWorkingName.String()
|
2024-01-13 22:08:49 -06:00
|
|
|
|
|
|
|
line1 = append(line1, "git", "checkout", devel)
|
|
|
|
all = append(all, line1)
|
|
|
|
line2 = append(line2, "git", "merge", user)
|
|
|
|
all = append(all, line2)
|
|
|
|
line3 = append(line3, "git", "push")
|
|
|
|
all = append(all, line3)
|
2024-01-11 15:56:50 -06:00
|
|
|
|
|
|
|
rs.versionCmds = all
|
|
|
|
|
|
|
|
var tmp []string
|
|
|
|
// convert to displayable to the user text
|
|
|
|
for _, line := range all {
|
2024-01-10 18:18:01 -06:00
|
|
|
s := strings.Join(line, " ")
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "s =", s)
|
2024-01-11 15:56:50 -06:00
|
|
|
tmp = append(tmp, s)
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
2024-01-11 15:56:50 -06:00
|
|
|
|
2024-01-19 12:36:52 -06:00
|
|
|
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
|
2024-01-10 00:15:27 -06:00
|
|
|
}
|