2024-01-09 15:34:53 -06:00
|
|
|
package repostatus
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
import (
|
2024-01-23 10:52:17 -06:00
|
|
|
"path/filepath"
|
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 05:01:54 -06:00
|
|
|
"go.wit.com/gui"
|
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-14 10:00:42 -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
|
|
|
|
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()
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// figure out what the state of the git repository is
|
2024-01-13 23:29:27 -06:00
|
|
|
// rs.Update()
|
2024-01-11 15:56:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs *RepoStatus) drawGitBranches() {
|
|
|
|
rs.gitBranchesGroup = rs.window.Box().NewGroup("branches")
|
|
|
|
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 2, 2)
|
|
|
|
|
|
|
|
rs.masterDrop = gadgets.NewBasicDropdown(newgrid, "main branch")
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.develDrop = gadgets.NewBasicDropdown(newgrid, "devel branch")
|
|
|
|
rs.userDrop = gadgets.NewBasicDropdown(newgrid, "user branch")
|
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-11 15:56:50 -06:00
|
|
|
var master = ""
|
|
|
|
all := rs.getBranches()
|
|
|
|
for _, branch := range all {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "getBranches()", branch)
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.masterDrop.AddText(branch)
|
|
|
|
rs.develDrop.AddText(branch)
|
|
|
|
rs.userDrop.AddText(branch)
|
2024-01-11 15:56:50 -06:00
|
|
|
if branch == "master" {
|
|
|
|
master = "master"
|
|
|
|
}
|
|
|
|
if branch == "main" {
|
|
|
|
master = "main"
|
|
|
|
}
|
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// relabel the various gadgets with the right branch name
|
2024-01-13 20:30:33 -06:00
|
|
|
rs.masterBranchVersion.SetLabel(master)
|
2024-01-11 15:56:50 -06:00
|
|
|
|
|
|
|
var count *gui.Node
|
|
|
|
|
2024-01-13 20:30:33 -06:00
|
|
|
rs.showBranchesButton = newgrid.NewButton("show branches", func() {
|
2024-01-11 15:56:50 -06:00
|
|
|
all := rs.getBranches()
|
|
|
|
i := len(all)
|
2024-01-19 12:24:19 -06:00
|
|
|
count.SetText(strconv.Itoa(i) + " branches")
|
2024-01-11 15:56:50 -06:00
|
|
|
})
|
|
|
|
count = newgrid.NewLabel("")
|
2024-01-11 23:24:09 -06:00
|
|
|
|
2024-01-13 20:30:33 -06:00
|
|
|
rs.checkBranchesButton = newgrid.NewButton("check branches", func() {
|
|
|
|
if rs.CheckBranches() {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Branches are perfect")
|
2024-01-11 23:24:09 -06:00
|
|
|
} else {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "Branches are not perfect")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
newgrid.NewButton("parse git and go config", func() {
|
|
|
|
ScanGoSrc()
|
|
|
|
})
|
|
|
|
|
|
|
|
newgrid.NewButton("show .git/config", func() {
|
|
|
|
if rs.gitConfig == nil {
|
|
|
|
log.Log(WARN, "Nonexistant or damaged .git/config", rs.GetPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Log(WARN, ".git/config:", rs.realPath.String())
|
|
|
|
|
|
|
|
// The info:
|
|
|
|
for name, remote := range rs.gitConfig.remotes {
|
|
|
|
log.Log(WARN, " ", name, remote.url)
|
|
|
|
}
|
|
|
|
for name, branch := range rs.gitConfig.branches {
|
|
|
|
log.Log(WARN, " ", name, "remote:", branch.remote, "merge", branch.merge)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
newgrid.NewButton("check go.sum", func() {
|
|
|
|
if rs.ReadGoMod() {
|
|
|
|
log.Log(INFO, "parsed go.mod", rs.realPath.String())
|
|
|
|
} else {
|
|
|
|
log.Log(WARN, "Something went wrong parsing go.mod", rs.realPath.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Log(WARN, "go.sum:", rs.realPath.String())
|
|
|
|
for depname, version := range rs.goConfig {
|
|
|
|
log.Log(WARN, " ", depname, version)
|
2024-01-11 15:56:50 -06:00
|
|
|
}
|
2024-01-23 10:52:17 -06:00
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-01-23 10:52:17 -06:00
|
|
|
/*
|
|
|
|
func (rs *RepoStatus) ScanConfig(path string) {
|
|
|
|
log.Log(WARN, "repo =", path)
|
|
|
|
filename := filepath.Join(path, ".git/config")
|
|
|
|
|
|
|
|
rs.gitConfig, err := ReadGitConfig(filename)
|
|
|
|
if err != nil {
|
|
|
|
log.Log(WARN, "Error reading .git/config:", err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
rs.goConfig, err := ReadGoMod(path)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
func ScanGoSrc() {
|
|
|
|
for i, path := range listGitDirectories() {
|
|
|
|
log.Log(WARN, "repo =", i, path)
|
|
|
|
filename := filepath.Join(path, ".git/config")
|
|
|
|
gitConfig, err := readGitConfig(filename)
|
|
|
|
if err != nil {
|
|
|
|
log.Log(WARN, "Error reading .git/config:", err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// Example of printing the parsed config
|
|
|
|
for section, options := range gitConfig.branches {
|
|
|
|
log.Log(WARN, "\t", section, options)
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
_, err = ReadGoMod(path) // map[string]string {
|
|
|
|
if err != nil {
|
|
|
|
log.Log(WARN, "\tgo.sum scan failed")
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
func (rs *RepoStatus) drawGitStatus() {
|
|
|
|
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 10:52:17 -06:00
|
|
|
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "go/src")
|
|
|
|
rs.realPath = gadgets.NewOneLiner(newgrid, "fullpath")
|
|
|
|
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")
|
|
|
|
_, _, output := RunCmd("/home/jcarr/go/src/"+rs.repopath, 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-23 10:52:17 -06:00
|
|
|
// rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
|
|
|
|
// rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
|
|
|
|
// rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
|
2024-01-11 15:56:50 -06:00
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
|
|
|
err, b, output := RunCmd("/home/jcarr/go/src/"+rs.repopath, cmd)
|
|
|
|
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-20 21:18:03 -06:00
|
|
|
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")
|
|
|
|
})
|
|
|
|
|
2024-01-10 18:18:01 -06:00
|
|
|
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
|
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-10 18:18:01 -06:00
|
|
|
log.Warn("COMMIT IT HERE")
|
2024-01-18 00:57:43 -06:00
|
|
|
if !rs.runGitCommands() {
|
2024-01-11 15:56:50 -06:00
|
|
|
log.Warn("SOMETHING WENT WRONG")
|
|
|
|
}
|
2024-01-11 23:24:09 -06:00
|
|
|
rs.Update()
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
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-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel(newver)
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.minor.SetText("")
|
|
|
|
rs.revision.SetText("")
|
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-20 21:18:03 -06:00
|
|
|
rs.newversion.SetLabel(newver)
|
2024-01-17 03:59:13 -06:00
|
|
|
rs.revision.SetText("")
|
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))
|
|
|
|
rs.revision.SetText(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-11 15:56:50 -06:00
|
|
|
func (rs *RepoStatus) runGitCommands() bool {
|
|
|
|
for _, line := range rs.versionCmds {
|
|
|
|
s := strings.Join(line, " ")
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "NEED TO RUN:", s)
|
2024-01-14 15:43:47 -06:00
|
|
|
rs.develMerge.SetText(s)
|
2024-01-15 17:03:06 -06:00
|
|
|
err, b, output := runCmd(rs.repopath, 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()
|
|
|
|
user := rs.GetUserBranchName()
|
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
|
|
|
}
|