155 lines
3.7 KiB
Go
155 lines
3.7 KiB
Go
package repostatus
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
/*
|
|
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")
|
|
rs.incrementRevision()
|
|
rs.EnableSelectTag()
|
|
rs.setTag()
|
|
return
|
|
}
|
|
log.Log(INFO, "Is repo pushed upstream? git.wit.org or github?")
|
|
}
|
|
*/
|
|
|
|
/*
|
|
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")
|
|
}
|
|
rs.releaseVersion.SetLabel("Release Tag!")
|
|
rs.releaseVersion.Enable()
|
|
return true
|
|
}
|
|
*/
|
|
|
|
/*
|
|
func (rs *RepoStatus) runGitCommands(verbose bool) bool {
|
|
var line []string
|
|
for _, line = range rs.versionCmds {
|
|
s := strings.Join(line, " ")
|
|
if verbose {
|
|
log.Log(WARN, "RUNNING:", s)
|
|
}
|
|
rs.develMergeB.SetText(s)
|
|
r := rs.Run(line)
|
|
output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
|
|
if r.Error != nil {
|
|
log.Warn("ABEND EXECUTION")
|
|
log.Warn("error =", r.Error)
|
|
log.Warn("output =", output)
|
|
return false
|
|
}
|
|
if r.Exit != 0 {
|
|
log.Warn("Returned with exit =", r.Exit)
|
|
log.Warn("output was =", output)
|
|
}
|
|
log.Log(INFO, "RUN DONE")
|
|
}
|
|
return true
|
|
}
|
|
*/
|
|
|
|
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"))
|
|
}
|
|
|
|
/*
|
|
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
|
|
}
|
|
*/
|