merge automation

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-30 13:31:46 -06:00
parent 940096ff40
commit 78049e664d
4 changed files with 36 additions and 25 deletions

42
draw.go
View File

@ -53,6 +53,7 @@ func (rs *RepoStatus) drawGitBranches() {
} }
}) })
/*
newgrid.NewButton("show .git/config", func() { newgrid.NewButton("show .git/config", func() {
if rs.gitConfig == nil { if rs.gitConfig == nil {
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String()) log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
@ -68,6 +69,7 @@ func (rs *RepoStatus) drawGitBranches() {
log.Log(WARN, " ", name, "remote:", branch.remote, "merge", branch.merge) log.Log(WARN, " ", name, "remote:", branch.remote, "merge", branch.merge)
} }
}) })
*/
newgrid.NewButton("CheckDirty()", func() { newgrid.NewButton("CheckDirty()", func() {
if rs.CheckDirty() { if rs.CheckDirty() {
@ -77,6 +79,7 @@ func (rs *RepoStatus) drawGitBranches() {
} }
}) })
/*
newgrid.NewButton("CheckSafeGoSumRemake()", func() { newgrid.NewButton("CheckSafeGoSumRemake()", func() {
if ok, bad := rs.CheckSafeGoSumRemake(); ok { if ok, bad := rs.CheckSafeGoSumRemake(); ok {
log.Log(WARN, "CheckSafeGoSumRemake() is safe to redo") log.Log(WARN, "CheckSafeGoSumRemake() is safe to redo")
@ -102,6 +105,7 @@ func (rs *RepoStatus) drawGitBranches() {
newgrid.NewButton("MakeRedomod()", func() { newgrid.NewButton("MakeRedomod()", func() {
rs.MakeRedomod() rs.MakeRedomod()
}) })
*/
} }
func (rs *RepoStatus) drawGitStatus() { func (rs *RepoStatus) drawGitStatus() {
@ -144,21 +148,21 @@ func (rs *RepoStatus) SetGoSumStatus(s string) {
rs.goSumStatus.SetText(s) rs.goSumStatus.SetText(s)
} }
func (rs *RepoStatus) runDevelMergeB() bool { func (rs *RepoStatus) RunDevelMergeB() bool {
master := rs.mainWorkingName.String() master := rs.mainWorkingName.String()
log.Warn("runDevelMergeB() checking out master branch", master) log.Warn("RunDevelMergeB() checking out master branch", master)
rs.checkoutBranch("master", master) rs.checkoutBranch("master", master)
if rs.getCurrentBranchName() != master { if rs.getCurrentBranchName() != master {
log.Warn("runDevelMergeB() something went wrong switching to the master branch. full stop!") log.Warn("RunDevelMergeB() something went wrong switching to the master branch. full stop!")
return false return false
} }
log.Warn("runDevelMergeB() running runGitCommands()") log.Warn("RunDevelMergeB() running runGitCommands()")
if !rs.runGitCommands(true) { if !rs.runGitCommands(true) {
log.Warn("runDevelMergeB() SOMETHING WENT WRONG") log.Warn("RunDevelMergeB() SOMETHING WENT WRONG")
return false return false
} }
rs.Update() rs.Update()
log.Warn("runDevelMergeB() THINGS SEEM OK runGitCommands() returned true.") log.Warn("RunDevelMergeB() THINGS SEEM OK runGitCommands() returned true.")
return true return true
} }
@ -181,21 +185,21 @@ func (rs *RepoStatus) runReleaseVersionB() bool {
} }
func (rs *RepoStatus) runFullAutomation() bool { func (rs *RepoStatus) runFullAutomation() bool {
if !rs.runDevelMergeB() { if !rs.RunDevelMergeB() {
log.Warn("THINGS FAILED returned false") log.Warn("THINGS FAILED returned false")
return false return false
} }
log.Warn("THINGS SEEM OK returned true. can run this again?") log.Warn("THINGS SEEM OK returned true. can run this again?")
log.Warn("develMerge =", rs.develMerge.String()) log.Warn("develMerge =", rs.develMergeB.String())
label := "merge devel into " + rs.GetMasterBranchName() label := "merge devel into " + rs.GetMasterBranchName()
if label == rs.develMerge.String() { if label == rs.develMergeB.String() {
log.Warn("LABELS MATCH", label, rs.develMerge.String()) log.Warn("LABELS MATCH", label, rs.develMergeB.String())
if !rs.runDevelMergeB() { if !rs.RunDevelMergeB() {
log.Warn("THINGS FAILED returned false") log.Warn("THINGS FAILED returned false")
return false return false
} }
} }
if rs.develMerge.String() == "ready to release" { if rs.develMergeB.String() == "ready to release" {
log.Warn("THINGS SEEM OK ready to release") log.Warn("THINGS SEEM OK ready to release")
if rs.releaseVersion.String() == "Release!" { if rs.releaseVersion.String() == "Release!" {
log.Warn("releaseVersion == 'Release!'. safe to do release version HERE?") log.Warn("releaseVersion == 'Release!'. safe to do release version HERE?")
@ -229,9 +233,9 @@ func (rs *RepoStatus) drawGitCommands() {
}) })
label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String() label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
rs.develMerge = newgrid.NewButton(label, func() { rs.develMergeB = newgrid.NewButton(label, func() {
rs.Disable() rs.Disable()
if rs.runDevelMergeB() { if rs.RunDevelMergeB() {
log.Warn("THINGS SEEM OK fullAutomation() returned true.") log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else { } else {
log.Warn("THINGS FAILED fullAutomation() returned false") log.Warn("THINGS FAILED fullAutomation() returned false")
@ -240,9 +244,9 @@ func (rs *RepoStatus) drawGitCommands() {
}) })
label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String() label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
rs.develMerge = newgrid.NewButton(label, func() { rs.mainMergeB = newgrid.NewButton(label, func() {
rs.Disable() rs.Disable()
if rs.runDevelMergeB() { if rs.RunDevelMergeB() {
log.Warn("THINGS SEEM OK fullAutomation() returned true.") log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else { } else {
log.Warn("THINGS FAILED fullAutomation() returned false") log.Warn("THINGS FAILED fullAutomation() returned false")
@ -417,7 +421,7 @@ func (rs *RepoStatus) recommend() {
rs.EnableMergeDevel() rs.EnableMergeDevel()
rs.setMergeUserCommands() rs.setMergeUserCommands()
label := "merge user into " + rs.GetDevelBranchName() label := "merge user into " + rs.GetDevelBranchName()
rs.develMerge.SetLabel(label) rs.develMergeB.SetLabel(label)
return return
} }
log.Log(INFO, "Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String()) log.Log(INFO, "Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String())
@ -426,7 +430,7 @@ func (rs *RepoStatus) recommend() {
rs.EnableMergeDevel() rs.EnableMergeDevel()
rs.setMergeDevelCommands() rs.setMergeDevelCommands()
label := "merge devel into " + rs.GetMasterBranchName() label := "merge devel into " + rs.GetMasterBranchName()
rs.develMerge.SetLabel(label) rs.develMergeB.SetLabel(label)
return return
} }
rs.getLastTagVersion() rs.getLastTagVersion()
@ -477,7 +481,7 @@ func (rs *RepoStatus) runGitCommands(verbose bool) bool {
if verbose { if verbose {
log.Log(WARN, "RUNNING:", s) log.Log(WARN, "RUNNING:", s)
} }
rs.develMerge.SetText(s) rs.develMergeB.SetText(s)
err, b, output := runCmd(rs.realPath.String(), line) err, b, output := runCmd(rs.realPath.String(), line)
if err != nil { if err != nil {
log.Warn("ABEND EXECUTION") log.Warn("ABEND EXECUTION")

4
git.go
View File

@ -279,8 +279,8 @@ func (rs *RepoStatus) GetStatus() string {
if rs.userBranchVersion.String() != rs.develBranchVersion.String() { if rs.userBranchVersion.String() != rs.develBranchVersion.String() {
return "merge to devel" return "merge to devel"
} }
if rs.userBranchVersion.String() != rs.masterBranchVersion.String() { if rs.develBranchVersion.String() != rs.masterBranchVersion.String() {
return "ready to release" return "merge to main"
} }
if rs.lasttag.String() != rs.masterBranchVersion.String() { if rs.lasttag.String() != rs.masterBranchVersion.String() {
return "ready to tag version" return "ready to tag version"

View File

@ -38,7 +38,8 @@ type RepoStatus struct {
develWorkingName *gadgets.OneLiner develWorkingName *gadgets.OneLiner
userWorkingName *gadgets.OneLiner userWorkingName *gadgets.OneLiner
develMerge *gui.Node develMergeB *gui.Node
mainMergeB *gui.Node
releaseVersion *gui.Node releaseVersion *gui.Node
// vgroup *gui.Node // vgroup *gui.Node

View File

@ -46,6 +46,12 @@ func (rs *RepoStatus) Update() {
rs.recommend() rs.recommend()
rs.CheckBranches() rs.CheckBranches()
label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
rs.develMergeB.SetLabel(label)
label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
rs.mainMergeB.SetLabel(label)
}) })
rs.setSpeed(duration) rs.setSpeed(duration)
log.Log(INFO, "Update() END") log.Log(INFO, "Update() END")
@ -81,7 +87,7 @@ func (rs *RepoStatus) DisableEverything() {
rs.versionMessage.Disable() rs.versionMessage.Disable()
// disable the merge devel to master button // disable the merge devel to master button
rs.develMerge.Disable() rs.develMergeB.Disable()
// disable the tag a new version button // disable the tag a new version button
rs.releaseVersion.Disable() rs.releaseVersion.Disable()
@ -91,7 +97,7 @@ func (rs *RepoStatus) DisableEverything() {
func (rs *RepoStatus) EnableMergeDevel() { func (rs *RepoStatus) EnableMergeDevel() {
rs.DisableEverything() rs.DisableEverything()
rs.develMerge.Enable() rs.develMergeB.Enable()
} }
func (rs *RepoStatus) Disable() { func (rs *RepoStatus) Disable() {
@ -114,7 +120,7 @@ func (rs *RepoStatus) EnableSelectTag() {
// disable adding a tag message // disable adding a tag message
rs.versionMessage.Enable() rs.versionMessage.Enable()
rs.develMerge.SetLabel("ready to release") rs.develMergeB.SetLabel("ready to release")
if len(rs.versionMessage.String()) == 0 { if len(rs.versionMessage.String()) == 0 {
// force there to be a commit message // force there to be a commit message