repostatus/merge.go

155 lines
3.7 KiB
Go
Raw Normal View History

2024-02-16 20:36:31 -06:00
package repostatus
import (
"strings"
"go.wit.com/log"
)
2024-02-16 21:28:22 -06:00
/*
2024-02-16 20:36:31 -06:00
func (rs *RepoStatus) recommend() {
log.Log(INFO, "Is repo dirty?", rs.dirtyLabel.String())
log.Log(INFO, "list the known tags")
rs.DisableEverything()
rs.populateTags()
log.Log(INFO, "Does devel == user?", rs.develBranchVersion.String(), rs.userBranchVersion.String())
if rs.develBranchVersion.String() != rs.userBranchVersion.String() {
log.Log(INFO, "devel does not equal user")
log.Log(INFO, "merge or squash?")
rs.EnableMergeDevel()
rs.setMergeUserCommands()
label := "merge user into " + rs.GetDevelBranchName()
rs.develMergeB.SetLabel(label)
return
}
log.Log(INFO, "Does master == devel? ", rs.GetMasterVersion(), rs.GetDevelVersion())
if rs.GetMasterVersion() != rs.GetDevelVersion() {
log.Log(INFO, "master does not equal devel. merge devel into master")
rs.EnableMergeDevel()
rs.setMergeDevelCommands()
label := "merge devel into " + rs.GetMasterBranchName()
rs.develMergeB.SetLabel(label)
return
}
if rs.lasttag.String() != rs.GetMasterVersion() {
log.Log(INFO, "master does not equal last tag")
2024-02-23 00:10:30 -06:00
rs.incrementRevision()
2024-02-16 20:36:31 -06:00
rs.EnableSelectTag()
rs.setTag()
return
}
log.Log(INFO, "Is repo pushed upstream? git.wit.org or github?")
}
2025-01-07 04:58:05 -06:00
*/
2024-02-16 20:36:31 -06:00
2025-01-07 04:58:05 -06:00
/*
2024-02-16 20:36:31 -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
if !rs.setTag() {
log.Log(INFO, "tag sucked. fix your tag version")
rs.versionMessage.SetLabel("tag message (bad version)")
rs.releaseVersion.Disable()
return false
}
log.Log(INFO, "tag is valid!!!!")
rs.setGitCommands()
if rs.versionMessage.String() == "" {
log.Log(INFO, "tag message is empty!!!!")
rs.releaseVersion.Disable()
return false
}
if len(rs.versionMessage.String()) > 24 {
rs.versionMessage.SetLabel("tag message (too long)")
} else {
rs.versionMessage.SetLabel("tag message")
}
2024-02-23 00:10:30 -06:00
rs.releaseVersion.SetLabel("Release Tag!")
2024-02-16 20:36:31 -06:00
rs.releaseVersion.Enable()
return true
}
2025-01-07 04:58:05 -06:00
*/
2024-02-16 20:36:31 -06:00
2025-01-07 18:45:34 -06:00
/*
2024-02-16 20:36:31 -06:00
func (rs *RepoStatus) runGitCommands(verbose bool) bool {
2024-11-08 06:43:33 -06:00
var line []string
for _, line = range rs.versionCmds {
2024-02-16 20:36:31 -06:00
s := strings.Join(line, " ")
if verbose {
log.Log(WARN, "RUNNING:", s)
}
rs.develMergeB.SetText(s)
2024-11-08 06:43:33 -06:00
r := rs.Run(line)
output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
if r.Error != nil {
2024-02-16 20:36:31 -06:00
log.Warn("ABEND EXECUTION")
2024-11-08 06:43:33 -06:00
log.Warn("error =", r.Error)
2024-02-16 20:36:31 -06:00
log.Warn("output =", output)
return false
}
2024-11-08 06:43:33 -06:00
if r.Exit != 0 {
log.Warn("Returned with exit =", r.Exit)
log.Warn("output was =", output)
}
2024-02-16 20:36:31 -06:00
log.Log(INFO, "RUN DONE")
}
return true
}
2025-01-07 18:45:34 -06:00
*/
2024-02-16 20:36:31 -06:00
func (rs *RepoStatus) setGitCommands() {
var line1, line2, line3 []string
var all [][]string
newTag := rs.newversion.String()
line1 = append(line1, "git", "tag", "v"+newTag, "-m", rs.versionMessage.String())
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, " ")
log.Log(INFO, "s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
}
2025-01-07 04:58:05 -06:00
/*
func (rs *RepoStatus) IsCorrectMode(mode string) bool {
switch mode {
case "master":
if rs.GetCurrentBranchName() == rs.GetMasterBranchName() {
return true
} else {
return false
}
case "devel":
if rs.GetCurrentBranchName() == rs.GetDevelBranchName() {
return true
} else {
return false
}
case "user":
if rs.GetCurrentBranchName() == rs.GetUserBranchName() {
return true
} else {
return false
}
}
return false
}
2025-01-05 12:01:39 -06:00
*/