remove lots of old stuff!

This commit is contained in:
Jeff Carr 2025-01-07 04:58:05 -06:00
parent 2ea1113c72
commit 904a5e8568
11 changed files with 70 additions and 836 deletions

View File

@ -1,4 +1,4 @@
all:
all: goimports
GO111MODULE=off go vet
goimports:

View File

@ -57,15 +57,17 @@ func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
newgrid.NextRow()
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
/*
if rs.CheckBranches() {
log.Log(WARN, "Branches are perfect")
} else {
log.Log(WARN, "Branches are not perfect")
}
*/
})
newgrid.NextRow()
newgrid.NewButton("Revert master to devel", func() {
rs.RevertMasterToDevel()
// rs.RevertMasterToDevel()
})
}

160
common.go
View File

@ -1,11 +1,6 @@
package repostatus
import (
"os"
"strings"
"unicode"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@ -26,30 +21,10 @@ func (rs *RepoStatus) getChanges() string {
}
func (rs *RepoStatus) NoteChange(s string) {
log.Log(REPOWARN, "NoteChange() got", rs.String(), s)
rs.changed = true
rs.changes += s + "\n"
}
// deprecate this. returns the gopath right now
func (rs *RepoStatus) String() string {
// log.Warn("RepoStatus.String() is to be deprecated")
return rs.path.String()
}
// returns the filesystem path to the repo
func (rs *RepoStatus) Path() string {
if rs == nil {
log.Warn("rs == nil")
return ""
}
if rs.realPath == nil {
log.Warn("rs.realPath == nil")
return ""
}
return rs.realPath.String()
}
func (rs *RepoStatus) Show() {
if !rs.Ready() {
return
@ -87,138 +62,3 @@ func (rs *RepoStatus) Ready() bool {
}
return rs.ready
}
func (rs *RepoStatus) IsGoLang() bool {
if !rs.Ready() {
return false
}
if rs.isGoLang.String() == "true" {
return true
}
return false
}
// experiment to determine the golang package type
func (rs *RepoStatus) RepoType() string {
if !rs.IsGoLang() {
return ""
}
if !rs.Exists("go.mod") {
return ""
}
os.Setenv("GO111MODULE", "off")
cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
r := shell.PathRunLog(rs.Path(), cmd, INFO)
output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
if r.Error != nil {
log.Info("go package error:", r.Error)
}
return output
}
func (rs *RepoStatus) BinaryName() string {
// get the package name from the repo name
path := rs.String()
parts := strings.Split(path, "/")
name := parts[len(parts)-1]
return name
}
func (rs *RepoStatus) Build() bool {
if !rs.IsGoLang() {
return false
}
name := rs.BinaryName()
// removes the binary if it already exists
rs.Run([]string{"rm", "-f", name})
if rs.Exists(name) {
log.Warn("file could not be removed filename =", name)
return false
}
log.Info("need to build here", rs.String())
// rs.RunCmd([]string{"go", "build", "-v", "-x"})
rs.XtermBash([]string{"go", "build", "-v", "-x"})
if rs.Exists(name) {
log.Warn("build worked", name)
return true
}
log.Warn("build failed", name)
return false
}
func (rs *RepoStatus) GetTargetVersion() string {
return rs.targetReleaseVersion.String()
}
func (rs *RepoStatus) GetCurrentVersion() string {
return rs.currentVersion.String()
}
func (rs *RepoStatus) LastTag() string {
return rs.lasttag.String()
}
func (rs *RepoStatus) IncrementVersion() bool {
rs.incrementRevision()
rs.EnableSelectTag()
rs.setTag()
newtag := "v" + rs.newversion.String()
rs.targetReleaseVersion.SetText(newtag)
return true
}
// TODO: run this through the sanity check!
func (rs *RepoStatus) SetTargetVersion(s string) {
// todo: redo setTag to do increment logic
// func (rs *RepoStatus) setTag() bool {
rs.targetReleaseVersion.SetText(s)
}
func (rs *RepoStatus) IsPrivate() bool {
if rs.private.String() == "true" {
return true
}
return false
}
func (rs *RepoStatus) SetPrivate(b bool) {
if b {
rs.private.SetText("true")
} else {
rs.private.SetText("false")
}
}
func trimNonNumericFromStart(s string) string {
for i, r := range s {
if unicode.IsDigit(r) {
return s[i:]
}
}
return ""
}
func (rs *RepoStatus) DebianReleaseVersion() string {
lasttag := rs.GetLastTagVersion()
newv := trimNonNumericFromStart(lasttag)
if newv == "" {
newv = "0.0"
if lasttag != "" {
newv += "-" + lasttag
}
}
return newv
}
func (rs *RepoStatus) DebianCurrentVersion() string {
cbversion := rs.GetCurrentBranchVersion()
newv := trimNonNumericFromStart(cbversion)
if newv == "" {
newv = "0.0"
}
if rs.CheckDirty() {
newv += "-dirty"
}
return newv
}

336
git.go
View File

@ -2,13 +2,8 @@ package repostatus
import (
"errors"
"fmt"
"os/user"
"strings"
"time"
"unicode/utf8"
"io/ioutil"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
@ -44,28 +39,10 @@ func (rs *RepoStatus) Age() time.Duration {
var ErrorMissingGitConfig error = errors.New("missing .git/config")
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
/*
func (rs *RepoStatus) GitPull() (string, error) {
currentName := rs.GetCurrentBranchName()
if rs.IsOnlyLocalTag(currentName) {
return "", ErrorGitPullOnLocal
}
var cmd []string
cmd = append(cmd, "git", "pull")
r := rs.Run(cmd)
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
output = "git error_,,,_a_,,,_b_,,,c"
}
if r.Error == nil {
log.Log(REPOWARN, "git pull ran", rs.Path())
log.Log(REPOWARN, "git pull output", output)
} else {
log.Log(REPOWARN, "git pull error", rs.Path(), r.Error)
}
return output, r.Error
// remove this everything
func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
*/
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
if rs.CheckDirty() {
@ -90,102 +67,6 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) {
}
}
func (rs *RepoStatus) guessDevelWorkingName() {
if rs.TagExists("guidevel") {
rs.develWorkingName.SetValue("guidevel")
rs.develBranchVersion.SetLabel("guidevel")
return
}
if rs.TagExists("devel") {
rs.develWorkingName.SetValue("devel")
rs.develBranchVersion.SetLabel("devel")
return
}
// figure out what to do here
rs.develWorkingName.SetValue("develFIXME")
rs.develBranchVersion.SetLabel("develFIXME")
}
func (rs *RepoStatus) setUserWorkingName() {
usr, _ := user.Current()
uname := usr.Username
if rs.TagExists(uname) {
rs.userWorkingName.SetValue(uname)
rs.userBranchVersion.SetLabel(uname)
return
}
rs.userWorkingName.SetValue("need to create " + uname)
rs.userBranchVersion.SetLabel("need to create " + uname)
}
// returns "master", "devel", os.Username, etc
func (rs *RepoStatus) GetMasterBranchName() string {
name := rs.mainWorkingName.String()
return name
}
func (rs *RepoStatus) GetDevelBranchName() string {
name := rs.develWorkingName.String()
return name
}
func (rs *RepoStatus) GetUserBranchName() string {
name := rs.userWorkingName.String()
return name
}
// returns the git versions like "1.3-2-laksdjf" or whatever
func (rs *RepoStatus) GetMasterVersion() string {
name := rs.mainBranchVersion.String()
return name
}
func (rs *RepoStatus) GetDevelVersion() string {
name := rs.develBranchVersion.String()
return name
}
func (rs *RepoStatus) GetUserVersion() string {
name := rs.userBranchVersion.String()
return name
}
func (rs *RepoStatus) setMasterVersion(s string) {
old := rs.GetMasterVersion()
if old == s {
return
}
rs.mainBranchVersion.SetValue(s)
if old == "" {
return // don't note if there was nothing before
}
rs.NoteChange("master branch has been changed from " + old + " to " + s)
}
func (rs *RepoStatus) setDevelVersion(s string) {
old := rs.GetDevelVersion()
if old == s {
return
}
if old == "" {
// don't note nothing
} else {
rs.NoteChange("devel branch has been changed from " + old + " to " + s)
}
rs.develBranchVersion.SetValue(s)
}
func (rs *RepoStatus) setUserVersion(s string) {
old := rs.GetUserVersion()
if old == s {
return
}
if old == "" {
// don't note nothing
} else {
rs.NoteChange("user branch has been changed from " + old + " to " + s)
}
rs.userBranchVersion.SetValue(s)
}
func (rs *RepoStatus) GitState() string {
return rs.gitState.String()
}
@ -200,105 +81,48 @@ func (rs *RepoStatus) GetStatus() string {
}
func (rs *RepoStatus) setState() {
pb := rs.pb
rs.changed = false
if rs.CheckDirty() {
if pb.CheckDirty() {
log.Log(REPO, "CheckDirty() true")
rs.gitState.SetText("dirty")
return
}
if rs.GetUserVersion() != rs.GetDevelVersion() {
if pb.GetUserVersion() != pb.GetDevelVersion() {
rs.gitState.SetText("merge to devel")
return
}
if rs.GetDevelVersion() != rs.GetMasterVersion() {
if pb.GetDevelVersion() != pb.GetMasterVersion() {
rs.gitState.SetText("merge to main")
return
}
if rs.lasttag.String() != rs.GetMasterVersion() {
if pb.GetLastTag() != pb.GetMasterVersion() {
rs.gitState.SetText("unchanged")
return
}
if rs.CheckBranches() {
if pb.CheckBranches() {
log.Log(REPO, "Branches are Perfect")
rs.gitState.SetText("PERFECT")
return
}
log.Log(REPO, rs.String(), "Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
rs.gitState.SetText("unknown branches")
}
// TODO: make this report the error somewhere
// This is supposed to check all the branches to make sure
// the are the same. that was originally what this was for
// now I think it's jsut probably dumb old code that doesn't
// need to be here
// actually, this is to attempt to verify absolutely everything
// is pushed upstream before doing a rm -rf ~/go/src
// TODO: revisit this code in the autotypist later
func (rs *RepoStatus) CheckBranches() bool {
var hashCheck string
var perfect bool = true
all := rs.getBranches()
path := rs.realPath.String() + "/.git/refs/"
for _, b := range all {
parts := strings.Split(b, "/")
rdir := "heads"
if len(parts) == 2 {
rdir = "remotes"
}
fullfile := path + "/" + rdir + "/" + b
// check if the ref name is "HEAD". if so, skip
runeCount := utf8.RuneCountInString(fullfile)
// Convert the string to a slice of runes
runes := []rune(fullfile)
// Slice the last 4 runes
lastFour := runes[runeCount-4:]
if string(lastFour) == "HEAD" {
log.Log(REPO, "skip HEAD fullfile", fullfile)
continue
}
content, _ := ioutil.ReadFile(fullfile)
hash := strings.TrimSpace(string(content))
if hashCheck == "" {
hashCheck = hash
}
var cmd []string
cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash)
r := shell.PathRunLog(rs.Path(), cmd, INFO)
if r.Error != nil {
log.Log(WARN, "CheckBranches() git show error:", r.Error)
}
// git show -s --format=%ci <hash> will give you the time
// log.Log(REPO, fullfile)
if hash == hashCheck {
log.Log(REPO, "notsure why this git show is here", hash)
} else {
// log.Log(WARN, rs.String(), hash, output, b)
// log.Log(WARN, "UNKNOWN BRANCHES IN THIS REPO", cmd)
rs.versionCmdOutput.SetText("UNKNOWN BRANCHES")
perfect = false
// parts := strings.Split(b, "/")
// log.Warn("git push", parts)
}
}
return perfect
}
/*
// this isn't right
func (rs *RepoStatus) LastTagAge() (time.Time, string) {
return time.Now(), rs.lasttag.String()
}
*/
func (rs *RepoStatus) GetLastTagVersion() string {
return rs.lasttag.String()
}
func (rs *RepoStatus) displayCurrentBranchName() string {
out := rs.pb.GetCurrentBranchName()
rs.currentBranch.SetValue(out)
return out
}
// stores the current branch name
func (rs *RepoStatus) checkCurrentBranchName() string {
currentname := rs.currentBranch.String()
@ -319,7 +143,7 @@ func (rs *RepoStatus) gitDescribeByHash(hash string) (string, error) {
if hash == "" {
return "", errors.New("hash was blank")
}
r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always", hash}, INFO)
r := shell.PathRunLog(rs.realPath.String(), []string{"git", "describe", "--tags", "--always", hash}, INFO)
out := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Warn("not in a git repo or bad hash?", r.Error, rs.Path())
@ -358,8 +182,7 @@ func (rs *RepoStatus) gitDescribeByName(name string) (string, error) {
// todo: don't run git every time?
func (rs *RepoStatus) checkCurrentBranchVersion() string {
out, _ := rs.gitDescribeByName("")
log.Log(REPO, "checkCurrentBranchVersion()", out)
out := rs.pb.GetCurrentVersion()
rs.currentVersion.SetValue(out)
return out
}
@ -406,12 +229,10 @@ func (rs *RepoStatus) getBranches() []string {
// returns quickly based on the last time it was checked
func (rs *RepoStatus) IsDirty() bool {
if rs.dirtyLabel.String() == "no" {
return false
}
return true
return rs.pb.IsDirty()
}
/*
// return the list of dirty files (but ignores go.mod & go.sum)
func (rs *RepoStatus) DirtyList() []string {
var all []string
@ -431,56 +252,18 @@ func (rs *RepoStatus) DirtyList() []string {
}
return all
}
*/
func (rs *RepoStatus) CheckDirty() bool {
var start string = rs.dirtyLabel.String()
cmd := []string{"git", "status", "--porcelain"}
r := shell.PathRunLog(rs.Path(), cmd, INFO)
out := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Warn("CheckDirty() status cmd =", cmd)
log.Warn("CheckDirty() status out =", out)
log.Warn("CheckDirty() status err =", r.Error)
log.Error(r.Error, "CheckDirty() git status error")
rs.dirtyLabel.SetValue("error")
if start != "error" {
rs.NoteChange("git status is in error " + fmt.Sprint(r.Error))
}
return true
}
rs.dirtyList = out
// last := out[strings.LastIndex(out, "\n")+1:]
// if last == "nothing to commit, working tree clean" {
if len(rs.DirtyList()) == 0 {
log.Log(REPO, "CheckDirty() no", rs.realPath.String())
rs.dirtyLabel.SetValue("no")
if start == "" {
// don't record a change as this is the initial run
return false
}
if start != "no" {
log.Log(REPOWARN, "is no longer dirty")
rs.NoteChange("is no longer dirty")
}
return false
}
if rs.pb.IsDirty() {
rs.dirtyLabel.SetValue("dirty")
if start == "" {
// don't record a change as this is the initial run
return false
}
if start != "dirty" {
log.Log(REPOWARN, "is now dirty")
rs.NoteChange("is now dirty")
}
return true
}
rs.dirtyLabel.SetValue("")
return false
}
/*
func (rs *RepoStatus) CheckoutBranch(bname string) bool {
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
@ -507,63 +290,4 @@ func (rs *RepoStatus) CheckoutBranch(bname string) bool {
rs.checkCurrentBranchVersion()
return true
}
func (rs *RepoStatus) CheckoutMaster() bool {
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
return false
}
mName := rs.GetMasterBranchName()
if rs.CheckoutBranch(mName) {
return true
}
return true
}
func (rs *RepoStatus) CheckoutDevel() bool {
devel := rs.develWorkingName.String()
// user := rs.userWorkingName.String()
if devel == "" {
return false
}
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
return false
}
log.Log(REPO, "checkoutBranch", devel)
rs.checkoutBranch("devel", devel)
// log.Log(REPO, "checkoutBranch", user)
// rs.checkoutBranch("user", user)
return true
}
func (rs *RepoStatus) CheckoutUser() bool {
bName := rs.GetUserBranchName()
if bName == "" {
return false
}
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
return false
}
if !rs.BranchExists(bName) {
return false
}
cmd := []string{"git", "checkout", bName}
r := rs.Run(cmd)
if r.Error != nil {
log.Log(REPO, "git checkout error:", r.Error)
}
realname := rs.GetCurrentBranchName()
realversion := rs.GetCurrentBranchVersion()
log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
if realname != bName {
log.Log(REPO, "git checkout failed", rs.realPath.String(), bName, "!=", realname)
return false
}
rs.userBranchVersion.SetValue(realversion)
return true
}
*/

View File

@ -259,7 +259,7 @@ func (rs *RepoStatus) processBranch(branch string) {
data, err := ioutil.ReadFile(filename)
if err != nil {
log.Log(WARN, "hash: read failed", filename, rs.String())
log.Log(WARN, "hash: read failed", filename, rs.Path())
return
}
newhash := strings.TrimSpace(string(data))
@ -267,7 +267,7 @@ func (rs *RepoStatus) processBranch(branch string) {
rs.gitConfig.hashes[branch] = newhash
if ok {
if hash != newhash {
log.Log(WARN, "hash changed", hash, rs.String())
log.Log(WARN, "hash changed", hash, rs.Path())
}
}

324
merge.go
View File

@ -1,233 +1,12 @@
package repostatus
import (
"errors"
"strconv"
"strings"
"go.wit.com/log"
"go.wit.com/widget"
)
// used to block commits on non-user branches
func (rs *RepoStatus) IsUserBranch() bool {
if rs.GetCurrentBranchName() == rs.GetUserBranchName() {
return true
}
return false
}
func (rs *RepoStatus) DeleteUserBranch(force bool) bool {
log.Log(REPOWARN, "figure out what to do here")
return false
}
func (rs *RepoStatus) ResetBranches() bool {
log.Log(REPOWARN, "figure out what to do here")
return false
}
func (rs *RepoStatus) FetchMaster() (error, string) {
// log.Log(REPOWARN, "FetchMaster() start", rs.Name())
master := rs.GetMasterBranchName()
return rs.fetchBranchByName(master)
}
func (rs *RepoStatus) FetchDevel() (error, string) {
devel := rs.GetDevelBranchName()
return rs.fetchBranchByName(devel)
}
// fetch the branch by name
func (rs *RepoStatus) fetchBranchByName(bname string) (error, string) {
if rs.GetCurrentBranchName() != rs.GetUserBranchName() {
return errors.New("not in user branch"), ""
}
if rs.gitConfig == nil {
return errors.New("missing .git/config"), ""
}
for name, branch := range rs.gitConfig.branches {
if name == bname {
// found the branch!
log.Log(REPO, " ", name, "remote:", branch.remote, "merge", branch.merge)
cmd := []string{"git", "fetch", branch.remote, bname + ":" + bname}
r := rs.Run(cmd)
output := strings.Join(r.Stdout, "\n")
return r.Error, strings.TrimSpace(output)
}
}
return errors.New("branch " + bname + " not found"), ""
}
/*
func (rs *RepoStatus) runFullAutomation() bool {
if !rs.MergeUserToDevel() {
log.Warn("THINGS FAILED returned false")
return false
}
log.Warn("THINGS SEEM OK returned true. can run this again?")
return true
}
*/
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)
}
func (rs *RepoStatus) SetVersion(a, b, c string, reason string) {
rs.major.SetText(a)
rs.minor.SetText(b)
releaseRevision = c
rs.setRevision(c)
rs.targetReleaseVersion.SetText("v" + a + "." + b + "." + c)
rs.versionMessage.SetLabel(reason)
rs.versionMessage.SetText(reason)
// rs.versionMessage.SetValue(reason)
}
func (rs *RepoStatus) IncrementMinorVersion(reason string) {
lasttag := rs.lasttag.String()
var major, minor, revision string
major, minor, revision = splitVersion(lasttag)
olda, _ := strconv.Atoi(major)
oldb, _ := strconv.Atoi(minor)
oldc, _ := strconv.Atoi(revision)
oldb += 1
oldc = 0
newa := strconv.Itoa(olda)
newb := strconv.Itoa(oldb)
newc := strconv.Itoa(oldc)
rs.SetVersion(newa, newb, newc, reason)
}
func (rs *RepoStatus) IncrementRevisionVersion(reason string) {
lasttag := rs.lasttag.String()
var major, minor, revision string
major, minor, revision = splitVersion(lasttag)
olda, _ := strconv.Atoi(major)
oldb, _ := strconv.Atoi(minor)
oldc, _ := strconv.Atoi(revision)
oldc += 1
newa := strconv.Itoa(olda)
newb := strconv.Itoa(oldb)
newc := strconv.Itoa(oldc)
rs.SetVersion(newa, newb, newc, reason)
}
func (rs *RepoStatus) setTag() bool {
lasttag := rs.lasttag.String()
var major, minor, revision string
major, minor, revision = splitVersion(lasttag)
olda, _ := strconv.Atoi(major)
oldb, _ := strconv.Atoi(minor)
oldc, _ := strconv.Atoi(revision)
log.Log(INFO, "current version here", lasttag)
log.Log(INFO, "current release a,b,c =", major, minor, revision)
newa, _ := strconv.Atoi(rs.major.String())
newver := strconv.Itoa(newa)
if newa < olda {
log.Warn("new version bad", newver, "vs old version", lasttag, "newa =", newa, "olda =", olda)
rs.newversion.SetLabel("bad")
return false
}
if newa > olda {
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
rs.minor.SetText("0")
rs.setRevision("0")
newver := strconv.Itoa(newa) + ".0.0"
rs.newversion.SetLabel(newver)
return true
}
newb, _ := strconv.Atoi(rs.minor.String())
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb)
if newb < oldb {
log.Warn("new version bad", newver, "vs old version", lasttag, "newb =", newb, "oldb =", oldb)
rs.newversion.SetLabel("bad")
return false
}
if newb > oldb {
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + ".0"
rs.newversion.SetLabel(newver)
rs.setRevision("0")
return true
}
newc, _ := strconv.Atoi(rs.revision.String())
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + "." + strconv.Itoa(newc)
if newc <= oldc {
log.Warn("new version bad", newver, "vs old version", lasttag)
rs.newversion.SetLabel("bad")
return false
}
log.Log(INFO, "new version ok", newver, "vs old version", lasttag)
rs.newversion.SetLabel(newver)
return true
}
// the newversion field goes through some sanity checking
// to make sure it's greater than the existing tag and
// valid according to golang -- it must be format 'v1.2.3'
func (rs *RepoStatus) GetNewVersionTag() string {
return rs.newversion.String()
}
func (rs *RepoStatus) incrementRevision() {
lasttag := rs.lasttag.String()
var major, minor, revision string
if rs.targetReleaseVersion.String() == "" {
major, minor, revision = splitVersion(lasttag)
log.Warn("Should release version here", lasttag)
log.Log(INFO, "Should release a,b,c", major, minor, revision)
} else {
// this means there is a specific release version trying to be done
// use the target release version instead
major, minor, revision = splitVersion(rs.targetReleaseVersion.String())
log.Warn("Should release version here", lasttag)
log.Log(INFO, "Should release a,b,c", major, minor, revision)
}
a, _ := strconv.Atoi(major)
b, _ := strconv.Atoi(minor)
c, _ := strconv.Atoi(revision)
rs.major.AddText(widget.GetString(a))
rs.major.AddText(widget.GetString(a + 1))
rs.major.SetText(widget.GetString(a))
rs.minor.AddText(widget.GetString(b))
rs.minor.AddText(widget.GetString(b + 1))
rs.minor.SetText(widget.GetString(b))
// rs.c := strconv.Atoi(revision)
rs.revision.AddText(strconv.Itoa(c + 1))
rs.revision.AddText(strconv.Itoa(c + 2))
rs.revision.SetText(strconv.Itoa(c + 1))
// rs.setRevision(widget.GetString(c + 1))
}
func (rs *RepoStatus) recommend() {
log.Log(INFO, "Is repo dirty?", rs.dirtyLabel.String())
log.Log(INFO, "list the known tags")
@ -261,7 +40,9 @@ func (rs *RepoStatus) recommend() {
}
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
@ -292,6 +73,7 @@ func (rs *RepoStatus) generateCmd() bool {
rs.releaseVersion.Enable()
return true
}
*/
func (rs *RepoStatus) runGitCommands(verbose bool) bool {
var line []string
@ -343,60 +125,7 @@ func (rs *RepoStatus) setGitCommands() {
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
}
func (rs *RepoStatus) setMergeDevelCommands() {
var line1, line2, line3 []string
var all [][]string
master := rs.GetMasterBranchName()
devel := rs.GetDevelBranchName()
line1 = append(line1, "git", "checkout", master)
all = append(all, line1)
line2 = append(line2, "git", "merge", devel)
all = append(all, line2)
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, " ")
log.Log(INFO, "s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n"))
}
func (rs *RepoStatus) setMergeUserCommands() {
var line1, line2, line3 []string
var all [][]string
devel := rs.GetDevelBranchName()
user := rs.userWorkingName.String()
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)
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":
@ -420,49 +149,4 @@ func (rs *RepoStatus) IsCorrectMode(mode string) bool {
}
return false
}
/* moved to gitpb
func (rs *RepoStatus) MergeUserToDevel() bool {
startbranch := rs.GetCurrentBranchName()
devel := rs.GetDevelBranchName()
user := rs.GetUserBranchName()
log.Info("MergeUserToDevel() checking out", devel, "started on", startbranch, "merge", user)
var all [][]string
all = append(all, []string{"git", "checkout", devel})
all = append(all, []string{"git", "merge", user})
all = append(all, []string{"git", "push"})
if rs.DoAll(all) {
log.Log(WARN, "MergeUserToDevel() failed", rs.Path())
rs.updateNew()
return true
}
// DoAll failed
rs.updateNew()
return false
}
func (rs *RepoStatus) MergeDevelToMaster() bool {
startbranch := rs.GetCurrentBranchName()
devel := rs.GetDevelBranchName()
main := rs.GetMasterBranchName()
log.Info("MergeDevelToMaster() checking out", main, "started on", startbranch, "merge", devel)
var all [][]string
all = append(all, []string{"git", "checkout", main})
all = append(all, []string{"git", "merge", devel})
all = append(all, []string{"git", "push"})
if rs.DoAll(all) {
log.Log(WARN, "MergeDevelToMaster() failed", rs.Path())
rs.updateNew()
return true
}
// DoAll failed
rs.updateNew()
return false
}
*/

View File

@ -24,7 +24,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
newgrid.NewButton("show .git/config", func() {
if rs.gitConfig == nil {
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
log.Log(WARN, "Nonexistant or damaged .git/config", rs.Path())
return
}
log.Log(WARN, ".git/config:", rs.realPath.String())
@ -66,30 +66,31 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
rs.Enable()
})
newgrid.NewButton("increment version", func() {
rs.IncrementVersion()
log.Info("broken")
// rs.IncrementVersion()
})
newgrid.NextRow()
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
rs.major.Custom = func() {
rs.setTag()
rs.generateCmd()
// rs.setTag()
// rs.generateCmd()
}
// rs.major.Hide()
newgrid.NextRow()
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
rs.minor.Custom = func() {
rs.setTag()
rs.generateCmd()
// rs.setTag()
// rs.generateCmd()
}
// rs.minor.Hide()
newgrid.NextRow()
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
rs.revision.Custom = func() {
rs.setTag()
rs.generateCmd()
// rs.setTag()
// rs.generateCmd()
}
// rs.revision.Hide()
newgrid.NextRow()
@ -101,7 +102,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
rs.versionMessage.Custom = func() {
rs.generateCmd()
// rs.generateCmd()
}
// rs.versionMessage.Hide()
newgrid.NextRow()

5
new.go
View File

@ -16,9 +16,6 @@ func init() {
// deprecate this
func ListAllOld() {
for path, rs := range windowMap {
log.Warn(rs.GetMasterVersion(), path)
}
}
// returns the object for the path
@ -103,7 +100,7 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
rs.userWorkingName.SetText(rs.pb.GetUserBranchName())
rs.userBranchVersion.SetLabel(rs.pb.GetUserBranchName())
if rs.pb.GetGoPath ()== "" {
if rs.pb.GetGoPath() == "" {
// not golang repo
} else {
rs.isGoLang.SetText("true")

View File

@ -1,9 +1,8 @@
package repostatus
import "go.wit.com/log"
// reverts master to devel
// used in the unwind process of making GUI releases
/*
func (rs *RepoStatus) RevertMasterToDevel() bool {
if rs.CheckDirty() {
log.Info("sorry, it's still dirty")
@ -39,3 +38,4 @@ func (rs *RepoStatus) RevertMasterToDevel() bool {
log.Info("SOMETHING FAILED")
return false
}
*/

View File

@ -51,7 +51,7 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
}
tagB := new(GitTagBox)
rs.Tags = tagB
tagB.group = box.NewGroup(".git tags for " + rs.String())
tagB.group = box.NewGroup(".git tags for " + rs.Path())
// tagB.group.NewButton("prune tags", func() {
// tagB.Prune()
@ -110,9 +110,9 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
all = append(all, []string{"git", "push", "--delete", "origin", tagversion})
if rs.DoAll(all) {
log.Info("TAG DELETED", rs.String(), tagversion)
log.Info("TAG DELETED", rs.Path(), tagversion)
} else {
log.Info("TAG DELETE FAILED", rs.String(), tagversion)
log.Info("TAG DELETE FAILED", rs.Path(), tagversion)
}
})

View File

@ -11,7 +11,7 @@ import (
func (rs *RepoStatus) gitBranchAll() {
r := rs.Run([]string{"git", "branch", "--all"})
if r.Error != nil {
log.Log(WARN, "git branch failed string =", rs.String())
log.Log(WARN, "git branch failed string =", rs.Path())
log.Log(WARN, "git branch failed realpath =", rs.realPath.String())
return
}
@ -27,6 +27,8 @@ func (rs *RepoStatus) updateNew() {
return
}
pb := rs.pb
// store the current checked out branch name and version
rs.checkCurrentBranchName()
rs.checkCurrentBranchVersion()
@ -35,33 +37,17 @@ func (rs *RepoStatus) updateNew() {
rs.populateTags()
// record if the repo is dirty
rs.CheckDirty()
pb.CheckDirty()
// store the last tag version
rs.setLastTagVersion()
// store the master branch version
mName := rs.GetMasterBranchName()
out, _ := rs.gitDescribeByName(mName)
rs.setMasterVersion(out)
ver := pb.GetMasterVersion()
rs.mainBranchVersion.SetValue(ver)
// store the devel branch version
dName := rs.GetDevelBranchName()
if dName == "" {
rs.setDevelVersion("")
} else {
out, _ = rs.gitDescribeByName(dName)
rs.setDevelVersion(out)
}
// store the user branch version
uName := rs.GetUserBranchName()
if uName == "" {
rs.setUserVersion("")
} else {
out, _ = rs.gitDescribeByName(uName)
rs.setUserVersion(out)
}
rs.develBranchVersion.SetValue(pb.GetDevelVersion())
rs.userBranchVersion.SetValue(pb.GetUserVersion())
// populates a string into the rs.gitState widget
// todo: make the values from this function a bit cleaner
@ -151,7 +137,7 @@ func (rs *RepoStatus) EnableSelectTag() {
// force there to be a commit message
rs.releaseVersion.Disable()
} else {
rs.generateCmd()
// rs.generateCmd()
rs.releaseVersion.Enable()
}
}