Compare commits
139 Commits
Author | SHA1 | Date |
---|---|---|
Jeff Carr | a15d447fbd | |
Jeff Carr | fcb74ce2e8 | |
Jeff Carr | 648d3ac6b6 | |
Jeff Carr | f53f1256f1 | |
Jeff Carr | 4efbead37c | |
Jeff Carr | 4dcd9a1164 | |
Jeff Carr | d9a54a6c31 | |
Jeff Carr | 9221f83aaf | |
Jeff Carr | e323d5920c | |
Jeff Carr | 07e0fdc437 | |
Jeff Carr | 669c4e082c | |
Jeff Carr | 904a5e8568 | |
Jeff Carr | 2ea1113c72 | |
Jeff Carr | 05d827868e | |
Jeff Carr | 3a53e0bd9b | |
Jeff Carr | 93e9e4e43b | |
Jeff Carr | 54cdb3fbec | |
Jeff Carr | 283bd90e91 | |
Jeff Carr | d5c394d3c3 | |
Jeff Carr | b52c3c426a | |
Jeff Carr | c25e4dd406 | |
Jeff Carr | e43863e8e7 | |
Jeff Carr | 9d13c972e4 | |
Jeff Carr | 2866815e3c | |
Jeff Carr | 4c46927bc7 | |
Jeff Carr | a1ce58e9d0 | |
Jeff Carr | 94e98f2145 | |
Jeff Carr | 9358005c9d | |
Jeff Carr | 2e8a1d4793 | |
Jeff Carr | 4ab00cce02 | |
Jeff Carr | a7c5499221 | |
Jeff Carr | 009d8f3b9d | |
Jeff Carr | 55acea0bd7 | |
Jeff Carr | 29545d3f04 | |
Jeff Carr | 5be028858c | |
Jeff Carr | 6b1330d7f3 | |
Jeff Carr | 3ce9f5f773 | |
Jeff Carr | 44ab5deb3f | |
Jeff Carr | 31355467a5 | |
Jeff Carr | e6f883a9b5 | |
Jeff Carr | 8eb7501855 | |
Jeff Carr | 8786690d46 | |
Jeff Carr | b451591006 | |
Jeff Carr | bf2a42ec64 | |
Jeff Carr | 5bc1a24a69 | |
Jeff Carr | 2ce9051921 | |
Jeff Carr | 804acc169a | |
Jeff Carr | 2622e90b1f | |
Jeff Carr | 7d3e4ce84e | |
Jeff Carr | 546ad6a842 | |
Jeff Carr | 54367ddc72 | |
Jeff Carr | 2cdf2c3cda | |
Jeff Carr | f99dc30b68 | |
Jeff Carr | 65a94faa57 | |
Jeff Carr | 412c84fcd9 | |
Jeff Carr | b2d3d13ed9 | |
Jeff Carr | b12bc0a9ec | |
Jeff Carr | 4d2f68606e | |
Jeff Carr | 035b4eb443 | |
Jeff Carr | fc849f6003 | |
Jeff Carr | 9a1347c03f | |
Jeff Carr | b354d7dd27 | |
Jeff Carr | cec5e7f3b4 | |
Jeff Carr | ccee573364 | |
Jeff Carr | ddd95e9afc | |
Jeff Carr | 2a62d23482 | |
Jeff Carr | 28a20e0922 | |
Jeff Carr | 5268267408 | |
Jeff Carr | 1b65474a69 | |
Jeff Carr | 5105bd4a99 | |
Jeff Carr | 359ebce26e | |
Jeff Carr | cd5f1d9d0f | |
Jeff Carr | 5aaf02ee3a | |
Jeff Carr | 70e8c98b1c | |
Jeff Carr | 2a19cd5eef | |
Jeff Carr | e1e81ab2bf | |
Jeff Carr | d16cc92286 | |
Jeff Carr | ae7e9ba42c | |
Jeff Carr | ad21d5d5db | |
Jeff Carr | be73f6af0e | |
Jeff Carr | 1bafc298d3 | |
Jeff Carr | 6a6ebf78b8 | |
Jeff Carr | 4d1301288e | |
Jeff Carr | 0e26f2024a | |
Jeff Carr | 45519f2370 | |
Jeff Carr | 6e7759f570 | |
Jeff Carr | f82743d487 | |
Jeff Carr | c7aaea4ae1 | |
Jeff Carr | 0b4f4d7686 | |
Jeff Carr | bd62a89a67 | |
Jeff Carr | 88ca40bcfa | |
Jeff Carr | 2bc2096e84 | |
Jeff Carr | e6eb92845a | |
Jeff Carr | 3d6002b055 | |
Jeff Carr | 73d711ad2b | |
Jeff Carr | d7e391fed0 | |
Jeff Carr | a223e9f1c3 | |
Jeff Carr | 07a60ffe3c | |
Jeff Carr | f7947b08b6 | |
Jeff Carr | 95fd6ca05a | |
Jeff Carr | d7a0246af9 | |
Jeff Carr | e7a3ef1298 | |
Jeff Carr | b4a571fb70 | |
Jeff Carr | ba4051cb0c | |
Jeff Carr | 2b172338f6 | |
Jeff Carr | b694fc2fe2 | |
Jeff Carr | 35e03959ab | |
Jeff Carr | 49724b16e8 | |
Jeff Carr | 678d6357b1 | |
Jeff Carr | 309cf80e16 | |
Jeff Carr | abb1f0ea21 | |
Jeff Carr | 118825e7a3 | |
Jeff Carr | 3937902a7d | |
Jeff Carr | 08b122ea2c | |
Jeff Carr | 4d665387fe | |
Jeff Carr | dbf10cddf7 | |
Jeff Carr | fae78b1812 | |
Jeff Carr | 1fda646fef | |
Jeff Carr | 78049e664d | |
Jeff Carr | 940096ff40 | |
Jeff Carr | ca09e7cf47 | |
Jeff Carr | a05f6c35ce | |
Jeff Carr | 7e7dbebcee | |
Jeff Carr | 408a400e93 | |
Jeff Carr | 856b479edb | |
Jeff Carr | 7bcbca3fce | |
Jeff Carr | e6cb846ccf | |
Jeff Carr | 318b748509 | |
Jeff Carr | 6d8a49d432 | |
Jeff Carr | 386125826f | |
Jeff Carr | 9147079092 | |
Jeff Carr | 2723e53396 | |
Jeff Carr | 9f26bc2d44 | |
Jeff Carr | 2aed84cf3a | |
Jeff Carr | 45e7aab862 | |
Jeff Carr | a80347531e | |
Jeff Carr | 86136ce615 | |
Jeff Carr | 4beeb0bb13 | |
Jeff Carr | 21546ce2c0 |
|
@ -1 +1,3 @@
|
|||
*.swp
|
||||
go.mod
|
||||
go.sum
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,7 +1,5 @@
|
|||
all:
|
||||
@echo
|
||||
@echo Run: make redomod
|
||||
@echo
|
||||
all: goimports
|
||||
GO111MODULE=off go vet
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
|
9
args.go
9
args.go
|
@ -12,6 +12,9 @@ var INFO *log.LogFlag
|
|||
var WARN *log.LogFlag
|
||||
var CHANGE *log.LogFlag
|
||||
|
||||
var REPO *log.LogFlag
|
||||
var REPOWARN *log.LogFlag
|
||||
|
||||
func init() {
|
||||
full := "go.wit.com/lib/gui/repostatus"
|
||||
short := "repostatus"
|
||||
|
@ -19,4 +22,10 @@ func init() {
|
|||
INFO = log.NewFlag("INFO", false, full, short, "general repo things")
|
||||
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
||||
CHANGE = log.NewFlag("CHANGE", true, full, short, "when repo changes")
|
||||
|
||||
full = "go.wit.com/lib/gui/repo"
|
||||
short = "repo"
|
||||
|
||||
REPO = log.NewFlag("REPO", false, full, short, "general repo things")
|
||||
REPOWARN = log.NewFlag("REPOWARN", true, full, short, "repo warnings")
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
|
||||
rs.gitBranchesGroup = parent.NewGroup("branches") // `progname:"BRANCHES"` // can the toolkits use these for i18n support?
|
||||
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0)
|
||||
|
||||
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") // `progname:"LASTTAG"`
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.mainBranchVersion = gadgets.NewOneLiner(newgrid, "master") // `progname:"MASTERBRANCH"`
|
||||
newgrid.NextRow()
|
||||
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel") // `progname:"DEVELBRANCH"`
|
||||
newgrid.NextRow()
|
||||
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user") // `progname:"USERBRANCH"`
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch") // `progname:"CURRENTBRANCH"`
|
||||
newgrid.NextRow()
|
||||
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version") // `progname:"CURRENTVERSION"`
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.switchBranchB = newgrid.NewButton("Switch Branch", func() { // `progname:"SWITCH"`
|
||||
/*
|
||||
bname := rs.targetBranch.String()
|
||||
log.Info("Should switch to branch", bname, "here")
|
||||
|
||||
var all [][]string
|
||||
all = append(all, []string{"git", "checkout", bname})
|
||||
if rs.DoAll(all) {
|
||||
log.Info("branch switched to", bname)
|
||||
} else {
|
||||
log.Info("branch switched to", bname, "failed")
|
||||
}
|
||||
rs.updateNew()
|
||||
*/
|
||||
})
|
||||
|
||||
rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"`
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.showBranchesButton = newgrid.NewButton("find jcarr and devel", func() {
|
||||
if rs.TagExists("jcarr") {
|
||||
log.Log(WARN, "tag jcarr exists")
|
||||
} else {
|
||||
log.Log(WARN, "tag jcarr does not exist")
|
||||
}
|
||||
if rs.TagExists("devel") {
|
||||
log.Log(WARN, "tag devel exists")
|
||||
} else {
|
||||
log.Log(WARN, "tag devel does not exist")
|
||||
}
|
||||
})
|
||||
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()
|
||||
})
|
||||
}
|
90
common.go
90
common.go
|
@ -2,27 +2,27 @@ package repostatus
|
|||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
// "go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
// reports externally if something has changed
|
||||
// since the last time it was asked about it
|
||||
func (rs *RepoStatus) Changed() bool {
|
||||
func (rs *RepoStatus) Changed() (string, bool) {
|
||||
if !rs.Ready() {
|
||||
return false
|
||||
return "", false
|
||||
}
|
||||
|
||||
return rs.changed
|
||||
return rs.getChanges(), rs.changed
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Draw() {
|
||||
if !rs.Ready() {
|
||||
return
|
||||
}
|
||||
log.Log(CHANGE, "Draw() window ready =", rs.ready)
|
||||
rs.window.TestDraw()
|
||||
// rs.window.Draw()
|
||||
rs.ready = true
|
||||
// keeps a human readable list of things that have
|
||||
// changed. todo: timestampe these?
|
||||
func (rs *RepoStatus) getChanges() string {
|
||||
return rs.changes
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) NoteChange(s string) {
|
||||
rs.changed = true
|
||||
rs.changes += s + "\n"
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Show() {
|
||||
|
@ -31,7 +31,6 @@ func (rs *RepoStatus) Show() {
|
|||
}
|
||||
log.Log(CHANGE, "Show() window ready =", rs.ready)
|
||||
rs.window.Show()
|
||||
rs.hidden = false
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Hide() {
|
||||
|
@ -40,7 +39,6 @@ func (rs *RepoStatus) Hide() {
|
|||
}
|
||||
log.Log(CHANGE, "Hide() window ready =", rs.ready)
|
||||
rs.window.Hide()
|
||||
rs.hidden = true
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Toggle() {
|
||||
|
@ -48,7 +46,7 @@ func (rs *RepoStatus) Toggle() {
|
|||
return
|
||||
}
|
||||
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
|
||||
if rs.hidden {
|
||||
if rs.window.Hidden() {
|
||||
rs.Show()
|
||||
} else {
|
||||
rs.Hide()
|
||||
|
@ -65,11 +63,59 @@ func (rs *RepoStatus) Ready() bool {
|
|||
return rs.ready
|
||||
}
|
||||
|
||||
/*
|
||||
func (rs *RepoStatus) Initialized() bool {
|
||||
log.Log(CHANGE, "checking Initialized()")
|
||||
if rs == nil {return false}
|
||||
if rs.parent == nil {return false}
|
||||
return true
|
||||
// disable all things besides Update() button
|
||||
func (rs *RepoStatus) DisableEverything() {
|
||||
log.Log(INFO, "DisableEverything()")
|
||||
|
||||
// choosing a major, minor or revision
|
||||
rs.major.Disable()
|
||||
rs.minor.Disable()
|
||||
rs.revision.Disable()
|
||||
|
||||
// disable adding a tag message
|
||||
rs.versionMessage.Disable()
|
||||
|
||||
// disable the merge devel to master button
|
||||
rs.develMergeB.Disable()
|
||||
|
||||
// disable the tag a new version button
|
||||
rs.releaseVersion.Disable()
|
||||
}
|
||||
|
||||
// this means devel needs to be merged to master
|
||||
func (rs *RepoStatus) EnableMergeDevel() {
|
||||
rs.DisableEverything()
|
||||
|
||||
rs.develMergeB.Enable()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Disable() {
|
||||
rs.window.Disable()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Enable() {
|
||||
rs.window.Enable()
|
||||
}
|
||||
|
||||
// this means you need to release a new version of the master repository
|
||||
func (rs *RepoStatus) EnableSelectTag() {
|
||||
rs.DisableEverything()
|
||||
|
||||
// choosing a major, minor or revision
|
||||
rs.major.Enable()
|
||||
rs.minor.Enable()
|
||||
rs.revision.Enable()
|
||||
|
||||
// disable adding a tag message
|
||||
rs.versionMessage.Enable()
|
||||
|
||||
rs.develMergeB.SetLabel("ready to release")
|
||||
|
||||
if len(rs.versionMessage.String()) == 0 {
|
||||
// force there to be a commit message
|
||||
rs.releaseVersion.Disable()
|
||||
} else {
|
||||
// rs.generateCmd()
|
||||
rs.releaseVersion.Enable()
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
461
draw.go
461
draw.go
|
@ -1,477 +1,36 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// creates the actual widgets.
|
||||
// it's assumed you are always passing in a box
|
||||
func (rs *RepoStatus) draw() {
|
||||
if !rs.Ready() {
|
||||
return
|
||||
}
|
||||
|
||||
// display the status of the git repository
|
||||
rs.drawGitStatus()
|
||||
|
||||
// display the git branches and options
|
||||
rs.drawGitBranches()
|
||||
|
||||
// show standard git commit and merge controls
|
||||
rs.drawGitCommands()
|
||||
}
|
||||
|
||||
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")
|
||||
rs.masterDrop.Custom = func() {
|
||||
log.Log(WARN, "Switching main branch to:", rs.masterDrop.String())
|
||||
rs.masterBranchVersion.SetLabel(rs.masterDrop.String())
|
||||
rs.mainWorkingName.SetValue(rs.masterDrop.String())
|
||||
}
|
||||
rs.develDrop = gadgets.NewBasicDropdown(newgrid, "devel branch")
|
||||
rs.develDrop.Custom = func() {
|
||||
log.Log(WARN, "Switching devel branch to:", rs.develDrop.String())
|
||||
rs.develBranchVersion.SetLabel(rs.develDrop.String())
|
||||
rs.develWorkingName.SetValue(rs.develDrop.String())
|
||||
}
|
||||
rs.userDrop = gadgets.NewBasicDropdown(newgrid, "user branch")
|
||||
rs.userDrop.Custom = func() {
|
||||
log.Log(WARN, "Switching user branch to:", rs.userDrop.String())
|
||||
rs.userBranchVersion.SetLabel(rs.userDrop.String())
|
||||
rs.userWorkingName.SetValue(rs.userDrop.String())
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
/*
|
||||
var master = ""
|
||||
all := rs.getBranches()
|
||||
for _, branch := range all {
|
||||
log.Log(INFO, "getBranches()", branch)
|
||||
rs.masterDrop.AddText(branch)
|
||||
rs.develDrop.AddText(branch)
|
||||
rs.userDrop.AddText(branch)
|
||||
if branch == "master" {
|
||||
master = "master"
|
||||
}
|
||||
if branch == "main" {
|
||||
master = "main"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// relabel the various gadgets with the right branch name
|
||||
// rs.masterBranchVersion.SetLabel(master)
|
||||
|
||||
rs.showBranchesButton = newgrid.NewButton("getBranches()", func() {
|
||||
all := rs.getBranches()
|
||||
i := len(all)
|
||||
log.Log(WARN, "branch count =", i)
|
||||
})
|
||||
|
||||
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
|
||||
if rs.CheckBranches() {
|
||||
log.Log(WARN, "Branches are perfect")
|
||||
} else {
|
||||
log.Log(WARN, "Branches are not perfect")
|
||||
}
|
||||
})
|
||||
|
||||
newgrid.NewButton("show .git/config", func() {
|
||||
if rs.gitConfig == nil {
|
||||
log.Log(WARN, "Nonexistant or damaged .git/config", rs.String())
|
||||
return
|
||||
}
|
||||
log.Log(WARN, ".git/config:", rs.realPath.String())
|
||||
|
||||
// The info:
|
||||
for name, remote := range rs.gitConfig.remotes {
|
||||
log.Log(WARN, " ", name, "url:", 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() {
|
||||
rs.CheckGoSum()
|
||||
})
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) drawGitStatus() {
|
||||
rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has")
|
||||
func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
|
||||
rs.gitStatusGroup = box.NewGroup("What GIT Knows It Has")
|
||||
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
||||
newgrid.Margin()
|
||||
newgrid.Pad()
|
||||
|
||||
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
||||
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
|
||||
rs.goPath = gadgets.NewOneLiner(newgrid, "go path")
|
||||
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
|
||||
rs.realPath.Hide()
|
||||
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
|
||||
rs.isGoLang.SetText("false")
|
||||
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")
|
||||
|
||||
// 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(rs.realPath.String(), cmd)
|
||||
log.Log(INFO, output)
|
||||
for _, line := range strings.Split(output, "\n") {
|
||||
rs.tagsDrop.AddText(line)
|
||||
}
|
||||
|
||||
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
|
||||
rs.gitState = gadgets.NewOneLiner(newgrid, "git state")
|
||||
rs.readOnly = gadgets.NewOneLiner(newgrid, "read only")
|
||||
rs.primitive = gadgets.NewOneLiner(newgrid, "primitive")
|
||||
rs.private = gadgets.NewOneLiner(newgrid, "private")
|
||||
rs.targetReleaseVersion = gadgets.NewOneLiner(newgrid, "target release version")
|
||||
|
||||
rs.speed = gadgets.NewOneLiner(newgrid, "refresh speed =")
|
||||
rs.speedActual = gadgets.NewOneLiner(newgrid, "speed actual =")
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) drawGitCommands() {
|
||||
rs.gitCommandsGroup = rs.window.Box().NewGroup("git commands")
|
||||
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 2, 2)
|
||||
|
||||
newgrid.NewButton("update", func() {
|
||||
rs.Update()
|
||||
})
|
||||
|
||||
newgrid.NewButton("git pull", func() {
|
||||
var cmd []string
|
||||
cmd = append(cmd, "git", "pull")
|
||||
err, b, output := RunCmd(rs.realPath.String(), cmd)
|
||||
log.Warn("Did git pull here", err, b, output)
|
||||
})
|
||||
|
||||
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
|
||||
rs.major.Custom = func() {
|
||||
rs.setTag()
|
||||
rs.generateCmd()
|
||||
}
|
||||
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
|
||||
rs.minor.Custom = func() {
|
||||
rs.setTag()
|
||||
rs.generateCmd()
|
||||
}
|
||||
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
|
||||
rs.revision.Custom = func() {
|
||||
rs.setTag()
|
||||
rs.generateCmd()
|
||||
}
|
||||
newgrid.NewLabel("new tag version")
|
||||
rs.newversion = newgrid.NewLabel("0.0.1")
|
||||
|
||||
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
|
||||
rs.versionMessage.Custom = func() {
|
||||
rs.generateCmd()
|
||||
}
|
||||
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
|
||||
|
||||
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")
|
||||
})
|
||||
|
||||
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
|
||||
if !rs.generateCmd() {
|
||||
log.Warn("something is wrong. fix the errors first")
|
||||
return
|
||||
}
|
||||
rs.releaseVersion.Disable()
|
||||
log.Warn("COMMIT IT HERE")
|
||||
if !rs.runGitCommands() {
|
||||
log.Warn("SOMETHING WENT WRONG")
|
||||
}
|
||||
rs.Update()
|
||||
log.Warn("THINGS SEEM OK")
|
||||
})
|
||||
|
||||
newgrid.Margin()
|
||||
newgrid.Pad()
|
||||
}
|
||||
|
||||
|
||||
func (rs *RepoStatus) SetVersion(a, b, c string, reason string) {
|
||||
rs.major.SetText(a)
|
||||
rs.minor.SetText(b)
|
||||
rs.revision.SetText(c)
|
||||
|
||||
rs.versionMessage.SetLabel(reason)
|
||||
rs.versionMessage.SetText(reason)
|
||||
// rs.versionMessage.SetValue(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.newversion.SetLabel(newver)
|
||||
rs.minor.SetText("")
|
||||
rs.revision.SetText("")
|
||||
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)
|
||||
rs.newversion.SetLabel(newver)
|
||||
rs.revision.SetText("")
|
||||
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
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) incrementVersion() {
|
||||
lasttag := rs.lasttag.String()
|
||||
var major, minor, revision string
|
||||
major, minor, revision = splitVersion(lasttag)
|
||||
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(widget.GetString(c + 1))
|
||||
rs.revision.AddText(widget.GetString(c + 2))
|
||||
rs.revision.SetText(widget.GetString(c + 1))
|
||||
}
|
||||
|
||||
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.develMerge.SetLabel(label)
|
||||
return
|
||||
}
|
||||
log.Log(INFO, "Does master == devel? ", rs.masterBranchVersion.String(), rs.develBranchVersion.String())
|
||||
if rs.masterBranchVersion.String() != rs.develBranchVersion.String() {
|
||||
log.Log(INFO, "master does not equal devel. merge devel into master")
|
||||
rs.EnableMergeDevel()
|
||||
rs.setMergeDevelCommands()
|
||||
label := "merge devel into " + rs.GetMasterBranchName()
|
||||
rs.develMerge.SetLabel(label)
|
||||
return
|
||||
}
|
||||
rs.getLastTagVersion()
|
||||
if rs.lasttag.String() != rs.masterBranchVersion.String() {
|
||||
log.Log(INFO, "master does not equal last tag")
|
||||
rs.incrementVersion()
|
||||
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.Enable()
|
||||
return true
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) runGitCommands() bool {
|
||||
for _, line := range rs.versionCmds {
|
||||
s := strings.Join(line, " ")
|
||||
log.Log(INFO, "NEED TO RUN:", s)
|
||||
rs.develMerge.SetText(s)
|
||||
err, b, output := runCmd(rs.realPath.String(), line)
|
||||
if err != nil {
|
||||
log.Warn("ABEND EXECUTION")
|
||||
log.Warn("error =", err)
|
||||
log.Warn("output =", output)
|
||||
return false
|
||||
}
|
||||
log.Log(INFO, "Returned with b =", b)
|
||||
log.Log(INFO, "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) 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.GetUserBranchName()
|
||||
|
||||
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"))
|
||||
}
|
||||
|
|
324
git.go
324
git.go
|
@ -1,293 +1,103 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (rs *RepoStatus) String() string {
|
||||
return rs.path.String()
|
||||
// remove this everything
|
||||
func (rs *RepoStatus) Path() string {
|
||||
return rs.realPath.String()
|
||||
}
|
||||
|
||||
/*
|
||||
func (rs *RepoStatus) GetPath() string {
|
||||
return rs.path.String()
|
||||
}
|
||||
*/
|
||||
|
||||
func (rs *RepoStatus) GetCurrentBranchName() string {
|
||||
return rs.currentBranch.String()
|
||||
func (rs *RepoStatus) GitState() string {
|
||||
return rs.gitState.String()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) GetCurrentBranchVersion() string {
|
||||
return rs.currentVersion.String()
|
||||
func (rs *RepoStatus) GetStatus() string {
|
||||
return rs.gitState.String()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) GetLastTagVersion() string {
|
||||
return rs.lasttag.String()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) getCurrentBranchName() string {
|
||||
out := run(rs.realPath.String(), "git", "branch --show-current")
|
||||
log.Log(INFO, "getCurrentBranchName() =", out)
|
||||
func (rs *RepoStatus) displayCurrentBranchName() string {
|
||||
out := rs.pb.GetCurrentBranchName()
|
||||
rs.currentBranch.SetValue(out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) getCurrentBranchVersion() string {
|
||||
out := run(rs.realPath.String(), "git", "describe --tags")
|
||||
log.Log(INFO, "getCurrentBranchVersion()", out)
|
||||
rs.currentVersion.SetValue(out)
|
||||
// stores the current branch name
|
||||
func (rs *RepoStatus) checkCurrentBranchName() string {
|
||||
currentname := rs.currentBranch.String()
|
||||
out := rs.pb.GetCurrentBranchName()
|
||||
if currentname == out {
|
||||
// nothing changed
|
||||
return currentname
|
||||
}
|
||||
rs.currentBranch.SetValue(out)
|
||||
if currentname == "" {
|
||||
return out // don't note if there was nothing before
|
||||
}
|
||||
rs.NoteChange("current branch has changed from " + currentname + " to " + out)
|
||||
return out
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) getLastTagVersion() string {
|
||||
out := run(rs.realPath.String(), "git", "rev-list --tags --max-count=1")
|
||||
log.Log(INFO, "getLastTagVersion()", out)
|
||||
// rs.lasttagrev = out
|
||||
func (rs *RepoStatus) gitDescribeByHash(hash string) (string, error) {
|
||||
if hash == "" {
|
||||
return "", errors.New("hash was blank")
|
||||
}
|
||||
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())
|
||||
return out, r.Error
|
||||
}
|
||||
return out, r.Error
|
||||
}
|
||||
|
||||
lastreal := "describe --tags " + out
|
||||
// out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1")
|
||||
out = run(rs.realPath.String(), "git", lastreal)
|
||||
rs.lasttag.SetValue(out)
|
||||
rs.tagsDrop.SetText(out)
|
||||
// rs.lastLabel.SetText(out)
|
||||
return out
|
||||
func (rs *RepoStatus) gitDescribeByName(name string) (string, error) {
|
||||
name = strings.TrimSpace(name)
|
||||
|
||||
if name == "" {
|
||||
// git will return the current tag
|
||||
r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always"}, INFO)
|
||||
output := strings.Join(r.Stdout, "\n")
|
||||
if r.Error != nil {
|
||||
log.Warn("gitDescribeByName() not in a git repo?", r.Error, rs.Path())
|
||||
}
|
||||
return strings.TrimSpace(output), r.Error
|
||||
}
|
||||
if !rs.LocalTagExists(name) {
|
||||
// tag does not exist
|
||||
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name")
|
||||
}
|
||||
cmd := []string{"git", "describe", "--tags", "--always", name}
|
||||
r := shell.PathRunLog(rs.Path(), cmd, INFO)
|
||||
output := strings.Join(r.Stdout, "\n")
|
||||
if r.Error != nil {
|
||||
log.Warn("cmd =", cmd)
|
||||
log.Warn("err =", r.Error)
|
||||
log.Warn("not in a git repo or bad tag?", rs.Path())
|
||||
}
|
||||
|
||||
return strings.TrimSpace(output), r.Error
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) populateTags() {
|
||||
tmp := rs.realPath.String() + "/.git/refs/tags"
|
||||
log.Log(INFO, "populateTags() path =", tmp)
|
||||
for _, tag := range listFiles(tmp) {
|
||||
log.Log(REPO, "populateTags() path =", tmp)
|
||||
for _, tag := range gitpb.ListFiles(tmp) {
|
||||
if rs.tags[tag] == "" {
|
||||
log.Log(INFO, "populateTags() Adding new tag", tag)
|
||||
rs.tagsDrop.AddText(tag)
|
||||
log.Log(REPO, "populateTags() Adding new tag", tag)
|
||||
// rs.tagsDrop.AddText(tag)
|
||||
rs.tags[tag] = "origin"
|
||||
}
|
||||
}
|
||||
// rs.tagsDrop.SetText(rs.lasttagrev)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) getBranches() []string {
|
||||
var all []string
|
||||
var heads []string
|
||||
var remotes []string
|
||||
heads = listFiles(rs.realPath.String() + "/.git/refs/heads")
|
||||
remotes = listFiles(rs.realPath.String() + "/.git/refs/remotes")
|
||||
|
||||
all = heads
|
||||
|
||||
all = append(all, remotes...)
|
||||
|
||||
for _, branch := range all {
|
||||
log.Log(INFO, "getBranches()", branch)
|
||||
}
|
||||
return all
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) CheckDirty() bool {
|
||||
cmd := []string{"git", "diff-index", "--quiet", "HEAD"}
|
||||
path := rs.realPath.String()
|
||||
err, b, out := RunCmd(path, cmd)
|
||||
if err != nil {
|
||||
log.Warn("CheckDirty() b =", b)
|
||||
log.Warn("CheckDirty() path =", path)
|
||||
log.Warn("CheckDirty() out =", out)
|
||||
log.Warn("CheckDirty() err =", err)
|
||||
log.Error(err, "CheckDirty() error")
|
||||
rs.dirtyLabel.SetValue("error")
|
||||
return true
|
||||
}
|
||||
if b {
|
||||
log.Log(INFO, "CheckDirty() b =", b, "path =", path, "out =", out)
|
||||
log.Log(INFO, "CheckDirty() no", rs.realPath.String())
|
||||
rs.dirtyLabel.SetValue("no")
|
||||
return false
|
||||
}
|
||||
log.Log(INFO, "CheckDirty() true", rs.realPath.String())
|
||||
rs.dirtyLabel.SetValue("dirty")
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) CheckoutBranch(branch string) (string, string) {
|
||||
// run(rs.realPath.String(), "git", "checkout " + branch)
|
||||
|
||||
realname := rs.getCurrentBranchName()
|
||||
realversion := rs.getCurrentBranchVersion()
|
||||
log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
|
||||
return realname, realversion
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
|
||||
if rs.CheckDirty() {
|
||||
log.Log(INFO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
|
||||
return
|
||||
}
|
||||
out := run(rs.realPath.String(), "git", "checkout "+branch)
|
||||
log.Log(INFO, rs.realPath.String(), "git checkout "+branch, "returned", out)
|
||||
|
||||
realname := rs.getCurrentBranchName()
|
||||
realversion := rs.getCurrentBranchVersion()
|
||||
log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
|
||||
|
||||
switch level {
|
||||
case "master":
|
||||
rs.masterBranchVersion.SetValue(realversion)
|
||||
case "devel":
|
||||
rs.develBranchVersion.SetValue(realversion)
|
||||
case "user":
|
||||
rs.userBranchVersion.SetValue(realversion)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) SetMainWorkingName(s string) {
|
||||
rs.mainWorkingName.SetValue(s)
|
||||
rs.masterDrop.SetLabel(s)
|
||||
rs.masterDrop.SetText("guimaster")
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) SetDevelWorkingName(s string) {
|
||||
rs.develWorkingName.SetValue(s)
|
||||
rs.develBranchVersion.SetLabel(s)
|
||||
rs.develDrop.SetLabel(s)
|
||||
rs.develDrop.SetText(s)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) SetUserWorkingName(s string) {
|
||||
rs.userWorkingName.SetValue(s)
|
||||
rs.userBranchVersion.SetLabel(s)
|
||||
rs.userDrop.SetText(s)
|
||||
}
|
||||
|
||||
// returns "master", "devel", os.Username, etc
|
||||
func (rs *RepoStatus) GetMasterBranchName() string {
|
||||
name := rs.masterDrop.String()
|
||||
return name
|
||||
}
|
||||
func (rs *RepoStatus) GetDevelBranchName() string {
|
||||
name := rs.develDrop.String()
|
||||
return name
|
||||
}
|
||||
func (rs *RepoStatus) GetUserBranchName() string {
|
||||
name := rs.userDrop.String()
|
||||
return name
|
||||
}
|
||||
|
||||
// returns the git versions like "1.3-2-laksdjf" or whatever
|
||||
func (rs *RepoStatus) GetMasterVersion() string {
|
||||
name := rs.masterBranchVersion.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) {
|
||||
if rs.GetMasterVersion() == s {
|
||||
return
|
||||
}
|
||||
rs.changed = true
|
||||
log.Verbose("git", rs.GetMasterBranchName(), "is now version =", s)
|
||||
rs.masterBranchVersion.SetValue(s)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) SetDevelVersion(s string) {
|
||||
if rs.GetDevelVersion() == s {
|
||||
return
|
||||
}
|
||||
rs.changed = true
|
||||
rs.develBranchVersion.SetValue(s)
|
||||
log.Verbose("git", rs.GetDevelBranchName(), "s now version =", s)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) SetUserVersion(s string) {
|
||||
if rs.GetUserVersion() == s {
|
||||
return
|
||||
}
|
||||
rs.changed = true
|
||||
rs.userBranchVersion.SetValue(s)
|
||||
log.Verbose("git", rs.GetUserBranchName(), "is now version =", s)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) GetStatus() string {
|
||||
rs.changed = false
|
||||
if rs.CheckDirty() {
|
||||
log.Log(INFO, "CheckDirty() true")
|
||||
return "dirty"
|
||||
}
|
||||
if rs.userBranchVersion.String() != rs.develBranchVersion.String() {
|
||||
return "merge to devel"
|
||||
}
|
||||
if rs.userBranchVersion.String() != rs.masterBranchVersion.String() {
|
||||
return "ready to release"
|
||||
}
|
||||
if rs.lasttag.String() != rs.masterBranchVersion.String() {
|
||||
return "ready to tag version"
|
||||
}
|
||||
|
||||
if rs.CheckBranches() {
|
||||
log.Log(INFO, "Branches are Perfect")
|
||||
return "PERFECT"
|
||||
}
|
||||
log.Log(INFO, rs.String(), "Branches are not Perfect")
|
||||
return "unknown branches"
|
||||
}
|
||||
|
||||
// TODO: make this report the error somewhere
|
||||
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(INFO, "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)
|
||||
_, _, output := RunCmd(rs.realPath.String(), cmd)
|
||||
// git show -s --format=%ci <hash> will give you the time
|
||||
// log.Log(INFO, fullfile)
|
||||
if hash == hashCheck {
|
||||
log.Log(INFO, hash, output, b)
|
||||
} else {
|
||||
log.Warn("UNKNOWN BRANCHES IN THIS REPO")
|
||||
rs.versionMessage.SetText("UNKNOWN BRANCHES")
|
||||
perfect = false
|
||||
parts := strings.Split(b, "/")
|
||||
log.Warn("git push", parts)
|
||||
}
|
||||
}
|
||||
return perfect
|
||||
}
|
||||
|
|
247
gitConfig.go
247
gitConfig.go
|
@ -2,6 +2,7 @@ package repostatus
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
|
||||
// GitConfig represents the parsed .git/config data
|
||||
// type GitConfig map[string]map[string]string
|
||||
// TODO: switch to protobuf
|
||||
|
||||
type remote struct {
|
||||
url string
|
||||
|
@ -23,55 +25,12 @@ type branch struct {
|
|||
}
|
||||
|
||||
type GitConfig struct {
|
||||
core map[string]string // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||
remotes map[string]*remote // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||
branches map[string]*branch // map[guimaster] = origin guimaster
|
||||
hashes map[string]string
|
||||
versions map[string]string
|
||||
}
|
||||
|
||||
type GoConfig map[string]string
|
||||
|
||||
func listGitDirectories() []string {
|
||||
var all []string
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error getting home directory:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
srcDir := filepath.Join(homeDir, "go/src")
|
||||
|
||||
err = filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error accessing path:", path, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if the current path is a directory and has a .git subdirectory
|
||||
if info.IsDir() && isGitDir(path) {
|
||||
all = append(all, path)
|
||||
// fmt.Println(path)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error walking the path:", srcDir, err)
|
||||
}
|
||||
|
||||
return all
|
||||
}
|
||||
|
||||
// isGitDir checks if a .git directory exists inside the given directory
|
||||
func isGitDir(dir string) bool {
|
||||
gitDir := filepath.Join(dir, ".git")
|
||||
info, err := os.Stat(gitDir)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
core map[string]string // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||
remotes map[string]*remote // map[origin] = "https:/git.wit.org/gui/gadgets"
|
||||
branches map[string]*branch // map[guimaster] = origin guimaster
|
||||
submodules map[string]string
|
||||
hashes map[string]string
|
||||
versions map[string]string
|
||||
}
|
||||
|
||||
// readGitConfig reads and parses the .git/config file
|
||||
|
@ -79,7 +38,13 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
filename := filepath.Join(rs.realPath.String(), "/.git/config")
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil
|
||||
log.Log(WARN, "readGitConfig() failed for file:", filename)
|
||||
filename = filepath.Join(rs.realPath.String(), "../.git/config")
|
||||
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
||||
file, err = os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
@ -90,6 +55,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
rs.gitConfig.core = make(map[string]string)
|
||||
rs.gitConfig.remotes = make(map[string]*remote)
|
||||
rs.gitConfig.branches = make(map[string]*branch)
|
||||
rs.gitConfig.submodules = make(map[string]string)
|
||||
rs.gitConfig.versions = make(map[string]string)
|
||||
rs.gitConfig.hashes = make(map[string]string)
|
||||
|
||||
|
@ -129,6 +95,11 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
switch currentSection {
|
||||
case "core":
|
||||
rs.gitConfig.core[key] = value
|
||||
case "gui":
|
||||
// don't really need gui stuff right now
|
||||
case "pull":
|
||||
// don't store git config pull settings here
|
||||
// probably has 'rebase = false'
|
||||
case "remote":
|
||||
test, ok := rs.gitConfig.remotes[currentName]
|
||||
if !ok {
|
||||
|
@ -145,7 +116,7 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
test.url = value
|
||||
continue
|
||||
}
|
||||
log.Log(WARN, "error url mismatch", test.url, value)
|
||||
log.Log(REPO, "error url mismatch", test.url, value)
|
||||
case "fetch":
|
||||
if test.fetch == value {
|
||||
continue
|
||||
|
@ -154,9 +125,9 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
test.fetch = value
|
||||
continue
|
||||
}
|
||||
log.Log(WARN, "error fetch mismatch", test.fetch, value)
|
||||
log.Log(REPO, "error fetch mismatch", test.fetch, value)
|
||||
default:
|
||||
log.Log(WARN, "error unknown remote:", currentSection, currentName, "key", key, "value", value)
|
||||
log.Log(REPO, "unknown remote:", line)
|
||||
}
|
||||
case "branch":
|
||||
test, ok := rs.gitConfig.branches[currentName]
|
||||
|
@ -171,10 +142,21 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
case "merge":
|
||||
rs.gitConfig.branches[currentName].merge = value
|
||||
default:
|
||||
log.Log(WARN, "error unknown remote:", currentSection, currentName, key, value)
|
||||
log.Log(REPO, "error unknown remote:", currentSection, currentName, key, value)
|
||||
log.Log(REPO, "unknown branch:", line)
|
||||
}
|
||||
case "submodule":
|
||||
// test, ok := rs.gitConfig.submodules[currentName]
|
||||
switch key {
|
||||
case "active":
|
||||
// probably 'true' or 'false'
|
||||
case "url":
|
||||
rs.gitConfig.submodules[currentName] = value
|
||||
default:
|
||||
log.Log(REPOWARN, "unknown submodule line:", line)
|
||||
}
|
||||
default:
|
||||
log.Log(WARN, "error unknown currentSection", currentSection, "line:", line)
|
||||
log.Log(REPOWARN, "unknown line:", line)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,161 +167,28 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// readGoMod reads and parses the go.sum file (TODO: do the go.mod file)
|
||||
func (rs *RepoStatus) ReadGoMod() bool {
|
||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
||||
gomod, err := os.Open(tmp)
|
||||
if err != nil {
|
||||
log.Log(WARN, "missing go.mod", rs.realPath.String())
|
||||
rs.goConfig = nil
|
||||
return false
|
||||
}
|
||||
defer gomod.Close()
|
||||
|
||||
tmp = filepath.Join(rs.realPath.String(), "go.sum")
|
||||
gosum, err := os.Open(tmp)
|
||||
if err != nil {
|
||||
log.Log(WARN, "missing go.sum", rs.realPath.String())
|
||||
rs.goConfig = nil
|
||||
return false
|
||||
}
|
||||
defer gosum.Close()
|
||||
|
||||
var deps GoConfig
|
||||
deps = make(GoConfig)
|
||||
|
||||
scanner := bufio.NewScanner(gosum)
|
||||
log.Log(INFO, "gosum:", tmp)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
|
||||
parts := strings.Split(line, " ")
|
||||
if len(parts) == 3 {
|
||||
godep := strings.TrimSpace(parts[0])
|
||||
version := strings.TrimSpace(parts[1])
|
||||
if strings.HasSuffix(version, "/go.mod") {
|
||||
version = strings.TrimSuffix(version, "/go.mod")
|
||||
}
|
||||
currentversion, ok := deps[godep]
|
||||
if ok {
|
||||
if currentversion != version {
|
||||
log.Log(WARN, "REPO:", rs.String(), rs.realPath.String())
|
||||
log.Log(WARN, " version mismatch:", godep, version, currentversion)
|
||||
}
|
||||
} else {
|
||||
deps[godep] = version
|
||||
log.Log(INFO, "\t", godep, "=", version)
|
||||
}
|
||||
} else {
|
||||
log.Log(WARN, "\t INVALID:", parts)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
rs.goConfig = nil
|
||||
return false
|
||||
}
|
||||
|
||||
rs.goConfig = deps
|
||||
return true
|
||||
}
|
||||
|
||||
func ScanGoSrc() {
|
||||
log.Log(WARN, "Scanning all go.sum files")
|
||||
for path, rs := range windowMap {
|
||||
if rs.ReadGoMod() {
|
||||
// everything is ok
|
||||
} else {
|
||||
log.Log(WARN, "failed reading go.sum repo:", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ScanGitConfig() {
|
||||
/*
|
||||
for i, path := range listGitDirectories() {
|
||||
filename := filepath.Join(path, ".git/config")
|
||||
_, err := readGitConfig(filename)
|
||||
if err != nil {
|
||||
log.Log(WARN, "repo =", i, path)
|
||||
log.Log(WARN, "Error reading .git/config:", err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) ScanGoSrc() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) CheckGoSum() bool {
|
||||
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())
|
||||
return false
|
||||
}
|
||||
log.Log(WARN, "go.sum:", rs.realPath.String())
|
||||
for depname, version := range rs.goConfig {
|
||||
log.Log(WARN, " ", depname, version)
|
||||
newrs, ok := windowMap[depname]
|
||||
if ok {
|
||||
if newrs.CheckDirty() {
|
||||
log.Log(WARN, " IS DIRTY", newrs.String())
|
||||
return false
|
||||
}
|
||||
log.Log(WARN, " FOUND", newrs.String())
|
||||
username := newrs.userWorkingName.String()
|
||||
userhash, _ := newrs.gitConfig.hashes[username]
|
||||
userversion, _ := newrs.gitConfig.versions[userhash]
|
||||
log.Log(WARN, " username :" + username, userhash)
|
||||
log.Log(WARN, " username :" + username, userversion)
|
||||
if version == userversion {
|
||||
log.Log(WARN, " USER VERSIONS MATCH", version, userversion)
|
||||
} else {
|
||||
log.Log(WARN, " USER VERSIONS MISMATCH", version, userversion)
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
log.Log(WARN, " NOT FOUND", depname)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) processBranch(branch string) {
|
||||
fullpath := rs.realPath.String()
|
||||
log.Log(WARN, " ", branch)
|
||||
log.Log(INFO, " ", branch)
|
||||
hash, ok := rs.gitConfig.hashes[branch]
|
||||
filename := fullpath + "/.git/refs/heads/" + branch
|
||||
log.Log(WARN, " hash: need to open", filename)
|
||||
newhash, err := readFileToString(filename)
|
||||
log.Log(INFO, " hash: need to open", filename)
|
||||
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
log.Log(WARN, " hash: read failed", filename)
|
||||
log.Log(WARN, "hash: read failed", filename)
|
||||
return
|
||||
}
|
||||
log.Log(WARN, " hash:", newhash)
|
||||
newhash := strings.TrimSpace(string(data))
|
||||
log.Log(INFO, " hash:", newhash)
|
||||
rs.gitConfig.hashes[branch] = newhash
|
||||
if ok {
|
||||
if hash != newhash {
|
||||
log.Log(WARN, " hash changed!!!!!!!!!", hash)
|
||||
log.Log(WARN, "hash changed", hash)
|
||||
}
|
||||
}
|
||||
|
||||
var cmd []string
|
||||
cmd = append(cmd, "git", "describe", "--tags", newhash)
|
||||
_, _, output := RunCmd(rs.realPath.String(), cmd)
|
||||
output = strings.TrimSpace(output)
|
||||
rs.gitConfig.versions[newhash] = output
|
||||
log.Log(WARN, " hash: version", output)
|
||||
name, _ := rs.gitDescribeByHash(newhash)
|
||||
rs.gitConfig.versions[newhash] = name
|
||||
log.Log(INFO, " hash: version", name)
|
||||
}
|
||||
|
|
16
go.mod
16
go.mod
|
@ -1,16 +0,0 @@
|
|||
module go.wit.com/lib/gui/repostatus
|
||||
|
||||
go 1.21.4
|
||||
|
||||
require (
|
||||
go.wit.com/gui v0.12.20
|
||||
go.wit.com/lib/gadgets v0.12.16
|
||||
go.wit.com/log v0.5.6
|
||||
go.wit.com/widget v1.1.6
|
||||
)
|
||||
|
||||
require (
|
||||
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
|
||||
go.wit.com/dev/davecgh/spew v1.1.4 // indirect
|
||||
)
|
14
go.sum
14
go.sum
|
@ -1,14 +0,0 @@
|
|||
go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY=
|
||||
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
||||
go.wit.com/gui v0.12.20 h1:mIc2DKGcpQjZdgtAj5qzkBrBDiteWfIaEpLyMnIBkh8=
|
||||
go.wit.com/gui v0.12.20/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||
go.wit.com/lib/gadgets v0.12.16 h1:xHz8zZiTe8xiGvfWs3s9drYUbePTT/Te58u7WXHjx0s=
|
||||
go.wit.com/lib/gadgets v0.12.16/go.mod h1:9779QoRZlk+G3/MCcX4Io1eH3HTLImE0AXdAMMdw+0U=
|
||||
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
|
||||
go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
||||
go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY=
|
||||
go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=
|
|
@ -0,0 +1,95 @@
|
|||
package repolist
|
||||
|
||||
// attempt to make a golang 'interface' for a 'view' of git repos
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.wit.com/lib/protobuf/virtbuf"
|
||||
)
|
||||
|
||||
// ViewRepoManager is a concrete implementation of the RepoManager interface.
|
||||
type ViewRepoManager struct {
|
||||
// client represents a hypothetical API client for interacting with the cloud.
|
||||
client ViewAPIClient
|
||||
}
|
||||
|
||||
// ViewAPIClient defines the methods required from the API client.
|
||||
// This is useful if you want to mock this client for testing.
|
||||
type ViewAPIClient interface {
|
||||
GetRepoByName(ctx context.Context, name string) (*virtbuf.Cluster, error)
|
||||
StartRepo(ctx context.Context, clusterID string) error
|
||||
StopRepo(ctx context.Context, clusterID string) error
|
||||
ListRepos(ctx context.Context) ([]*virtbuf.Cluster, error)
|
||||
GetRepoStatus(ctx context.Context, clusterID string) (string, error)
|
||||
}
|
||||
|
||||
// NewViewRepoManager creates a new ViewRepoManager with the provided API client.
|
||||
func NewViewRepoManager(client ViewAPIClient) *ViewRepoManager {
|
||||
return &ViewRepoManager{client: client}
|
||||
}
|
||||
|
||||
// FindByName retrieves a cluster by name.
|
||||
func (m *ViewRepoManager) FindByName(ctx context.Context, name string) (*virtbuf.Cluster, error) {
|
||||
cluster, err := m.client.GetRepoByName(ctx, name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error finding cluster by name %q: %w", name, err)
|
||||
}
|
||||
return cluster, nil
|
||||
}
|
||||
|
||||
// Start initiates the startup process for the specified cluster.
|
||||
func (m *ViewRepoManager) Start(ctx context.Context, cluster *virtbuf.Cluster) error {
|
||||
if cluster == nil {
|
||||
return errors.New("cluster cannot be nil")
|
||||
}
|
||||
/*
|
||||
err := m.client.StartRepo(ctx, cluster.Id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error starting cluster %q: %w", cluster.Id, err)
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop halts the specified cluster.
|
||||
func (m *ViewRepoManager) Stop(ctx context.Context, cluster *virtbuf.Cluster) error {
|
||||
if cluster == nil {
|
||||
return errors.New("cluster cannot be nil")
|
||||
}
|
||||
/*
|
||||
err := m.client.StopRepo(ctx, cluster.Id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error stopping cluster %q: %w", cluster.Id, err)
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
||||
// List retrieves all available clusters.
|
||||
func (m *ViewRepoManager) List(ctx context.Context) ([]*virtbuf.Cluster, error) {
|
||||
/*
|
||||
clusters, err := m.client.ListRepos(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing clusters: %w", err)
|
||||
}
|
||||
return clusters, nil
|
||||
*/
|
||||
return nil, errors.New("List not done yet")
|
||||
}
|
||||
|
||||
// Status checks the current status of a specified cluster.
|
||||
func (m *ViewRepoManager) Status(ctx context.Context, cluster *virtbuf.Cluster) (string, error) {
|
||||
if cluster == nil {
|
||||
return "", errors.New("cluster cannot be nil")
|
||||
}
|
||||
/*
|
||||
status, err := m.client.GetRepoStatus(ctx, cluster.Id)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error getting status of cluster %q: %w", cluster.Id, err)
|
||||
}
|
||||
*/
|
||||
return "", nil
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
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"))
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package repostatus
|
||||
|
||||
// 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")
|
||||
return false
|
||||
}
|
||||
|
||||
curName := rs.GetCurrentBranchName()
|
||||
dName := rs.GetDevelBranchName()
|
||||
mName := rs.GetMasterBranchName()
|
||||
if curName != mName {
|
||||
log.Info("repo is not working from main branch", curName, "!=", mName)
|
||||
return false
|
||||
}
|
||||
|
||||
log.Info("reset master to devel", curName, rs.String())
|
||||
|
||||
var all [][]string
|
||||
all = append(all, []string{"git", "checkout", dName}) // switch to the devel branch
|
||||
all = append(all, []string{"git", "branch", "-D", mName})
|
||||
all = append(all, []string{"git", "branch", mName}) // make a master branch based on devel
|
||||
all = append(all, []string{"git", "checkout", mName})
|
||||
all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName})
|
||||
|
||||
// don't do anything with tags here
|
||||
// all = append(all, []string{"git", "tag", "--delete", release.version.String()})
|
||||
// all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()})
|
||||
|
||||
if rs.DoAll(all) {
|
||||
log.Info("EVERYTHING OK. RERELEASED", rs.String())
|
||||
return true
|
||||
}
|
||||
|
||||
log.Info("SOMETHING FAILED")
|
||||
return false
|
||||
}
|
||||
*/
|
|
@ -17,3 +17,20 @@ func (ls *RepoStatus) SetSpeedActual(s string) {
|
|||
}
|
||||
ls.speedActual.SetValue(s)
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) setSpeed(duration time.Duration) {
|
||||
s := fmt.Sprint(duration)
|
||||
if rs.speedActual == nil {
|
||||
log.Log(WARN, "rs.speedActual == nil")
|
||||
return
|
||||
}
|
||||
rs.speedActual.SetValue(s)
|
||||
|
||||
if duration > 200*time.Millisecond {
|
||||
rs.speed.SetValue("SLOW")
|
||||
} else if duration > 50*time.Millisecond {
|
||||
rs.speed.SetValue("OK")
|
||||
} else {
|
||||
rs.speed.SetValue("FAST")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
|
||||
rs.gitCommandsGroup = box.NewGroup("modify")
|
||||
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 0, 0)
|
||||
|
||||
newgrid.NewButton("Rescan Repo", func() {
|
||||
rs.Update()
|
||||
})
|
||||
|
||||
newgrid.NewButton("CheckDirty()", func() {
|
||||
if rs.pb.CheckDirty() {
|
||||
log.Log(WARN, "is dirty")
|
||||
} else {
|
||||
log.Log(WARN, "is not dirty")
|
||||
}
|
||||
})
|
||||
|
||||
newgrid.NewButton("show .git/config", func() {
|
||||
if rs.gitConfig == nil {
|
||||
log.Log(WARN, "Nonexistant or damaged .git/config", rs.Path())
|
||||
return
|
||||
}
|
||||
log.Log(WARN, ".git/config:", rs.realPath.String())
|
||||
|
||||
// The info:
|
||||
for name, remote := range rs.gitConfig.remotes {
|
||||
log.Log(WARN, " ", name, "url:", remote.url)
|
||||
}
|
||||
for name, branch := range rs.gitConfig.branches {
|
||||
log.Log(WARN, " ", name, "remote:", branch.remote, "merge", branch.merge)
|
||||
}
|
||||
})
|
||||
newgrid.NextRow()
|
||||
|
||||
newgrid.NewButton("git pull", func() {
|
||||
rs.pb.GitPull()
|
||||
})
|
||||
newgrid.NextRow()
|
||||
|
||||
label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
|
||||
rs.develMergeB = newgrid.NewButton(label, func() {
|
||||
rs.Disable()
|
||||
if result, err := rs.pb.MergeUserToDevel(); err == nil {
|
||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
||||
} else {
|
||||
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
|
||||
}
|
||||
rs.Enable()
|
||||
})
|
||||
|
||||
label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
|
||||
rs.mainMergeB = newgrid.NewButton(label, func() {
|
||||
rs.Disable()
|
||||
if result, err := rs.pb.MergeDevelToMaster(); err == nil {
|
||||
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
||||
} else {
|
||||
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
|
||||
}
|
||||
rs.Enable()
|
||||
})
|
||||
newgrid.NewButton("increment version", func() {
|
||||
log.Info("broken")
|
||||
// rs.IncrementVersion()
|
||||
})
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
|
||||
rs.major.Custom = func() {
|
||||
// rs.setTag()
|
||||
// rs.generateCmd()
|
||||
}
|
||||
// rs.major.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
|
||||
rs.minor.Custom = func() {
|
||||
// rs.setTag()
|
||||
// rs.generateCmd()
|
||||
}
|
||||
// rs.minor.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
|
||||
rs.revision.Custom = func() {
|
||||
// rs.setTag()
|
||||
// rs.generateCmd()
|
||||
}
|
||||
// rs.revision.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
// newgrid.NewLabel("new tag version")
|
||||
rs.newversion = newgrid.NewLabel("0.0.1")
|
||||
// rs.newversion.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
|
||||
rs.versionMessage.Custom = func() {
|
||||
// rs.generateCmd()
|
||||
}
|
||||
// rs.versionMessage.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
|
||||
// rs.versionCmdOutput.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
|
||||
rs.Disable()
|
||||
rs.pb.MergeDevelToMaster()
|
||||
})
|
||||
// rs.releaseVersion.Hide()
|
||||
newgrid.NextRow()
|
||||
|
||||
newgrid.Margin()
|
||||
newgrid.Pad()
|
||||
}
|
178
new.go
178
new.go
|
@ -2,92 +2,112 @@ package repostatus
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
var windowMap map[string]*RepoStatus
|
||||
|
||||
func ListAll() {
|
||||
for path, rs := range windowMap {
|
||||
log.Warn(rs.GetMasterVersion(), path)
|
||||
}
|
||||
}
|
||||
|
||||
func NewRepoStatusWindow(path string) *RepoStatus {
|
||||
if windowMap[path] == nil {
|
||||
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
||||
} else {
|
||||
log.Warn("This already exists yet for path", path)
|
||||
log.Warn("should return windowMap[path] here")
|
||||
return windowMap[path]
|
||||
}
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error getting home directory:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
goSrcDir := filepath.Join(homeDir, "go/src")
|
||||
realpath := filepath.Join(goSrcDir, path)
|
||||
|
||||
filename := filepath.Join(goSrcDir, path, ".git/config")
|
||||
|
||||
_, err = os.Open(filename)
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error reading:", filename, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
rs := New(gui.TreeRoot(), path)
|
||||
rs.draw()
|
||||
|
||||
// save ~/go/src & the whole path strings
|
||||
rs.path.SetValue(path)
|
||||
rs.goSrcPath.SetValue(goSrcDir)
|
||||
rs.realPath.SetValue(realpath)
|
||||
|
||||
rs.readGitConfig()
|
||||
|
||||
rs.readOnly.SetValue("true")
|
||||
if strings.HasPrefix(path, "go.wit.com") {
|
||||
rs.readOnly.SetValue("false")
|
||||
}
|
||||
if strings.HasPrefix(path, "git.wit.org") {
|
||||
rs.readOnly.SetValue("false")
|
||||
}
|
||||
|
||||
windowMap[path] = rs
|
||||
|
||||
// todo check if a window already exists for this path
|
||||
return rs
|
||||
}
|
||||
|
||||
func New(p *gui.Node, path string) *RepoStatus {
|
||||
rs := &RepoStatus{
|
||||
hidden: true,
|
||||
ready: false,
|
||||
parent: p,
|
||||
}
|
||||
rs.tags = make(map[string]string)
|
||||
rs.window = gadgets.NewBasicWindow(p, "GO Repo Details "+path)
|
||||
rs.window.Horizontal()
|
||||
rs.window.Make()
|
||||
rs.ready = true
|
||||
rs.window.Custom = func() {
|
||||
// rs.hidden = true
|
||||
rs.Hide()
|
||||
log.Warn("repostatus user closed the window()")
|
||||
}
|
||||
windowMap[path] = rs
|
||||
return rs
|
||||
}
|
||||
|
||||
func init() {
|
||||
windowMap = make(map[string]*RepoStatus)
|
||||
}
|
||||
|
||||
/*
|
||||
// deprecate this
|
||||
func ListAllOld() {
|
||||
}
|
||||
|
||||
// returns the object for the path
|
||||
// deprecate this
|
||||
func FindPathOld(path string) *RepoStatus {
|
||||
if windowMap[path] == nil {
|
||||
log.Log(INFO, "FindPath() not initialized yet", path)
|
||||
return nil
|
||||
}
|
||||
return windowMap[path]
|
||||
}
|
||||
|
||||
func SetWorkPath(path string) {
|
||||
os.Setenv("REPO_WORK_PATH", path)
|
||||
}
|
||||
*/
|
||||
|
||||
// makes a window of the status of the repo
|
||||
// don't worry, you can think of it like Sierpinski carpet
|
||||
// it's doesn't need to be displayed so it'll work fine even in an embedded space
|
||||
func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
|
||||
path := repo.GetGoPath()
|
||||
if windowMap[path] == nil {
|
||||
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
||||
} else {
|
||||
log.Warn("This already exists for path", path)
|
||||
log.Warn("should return windowMap[path] here")
|
||||
return windowMap[path], nil
|
||||
}
|
||||
|
||||
rs := &RepoStatus{
|
||||
ready: false,
|
||||
}
|
||||
rs.pb = repo
|
||||
// realpath := repo.FullPath
|
||||
// isGoLang := true
|
||||
|
||||
rs.tags = make(map[string]string)
|
||||
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
||||
rs.window.Horizontal()
|
||||
rs.window.Make()
|
||||
basebox := rs.window.Box()
|
||||
group := basebox.NewGroup("stuff")
|
||||
primarybox := group.Box()
|
||||
primarybox.Horizontal()
|
||||
box2 := group.Box()
|
||||
rs.ready = true
|
||||
rs.window.Custom = func() {
|
||||
rs.Hide()
|
||||
log.Warn("repostatus user closed the window()")
|
||||
}
|
||||
|
||||
// display the status of the git repository
|
||||
rs.drawGitStatus(primarybox)
|
||||
|
||||
// display the git branches and options
|
||||
rs.makeBranchesBox(primarybox)
|
||||
|
||||
// show standard git commit and merge controls
|
||||
rs.drawGitCommands(primarybox)
|
||||
|
||||
// save ~/go/src & the whole path strings
|
||||
rs.path.SetValue(path)
|
||||
rs.goSrcPath.SetValue(os.Getenv("FORGE_GOSRC"))
|
||||
rs.realPath.SetValue(rs.pb.GetFullPath())
|
||||
|
||||
// add all the tags
|
||||
rs.makeTagBox(box2)
|
||||
|
||||
rs.readGitConfig()
|
||||
|
||||
if rs.pb.GetReadOnly() {
|
||||
rs.readOnly.SetValue("true")
|
||||
} else {
|
||||
rs.readOnly.SetValue("false")
|
||||
}
|
||||
rs.mainWorkingName.SetText(rs.pb.GetMasterBranchName())
|
||||
rs.mainBranchVersion.SetLabel(rs.pb.GetMasterBranchName())
|
||||
|
||||
rs.develWorkingName.SetText(rs.pb.GetDevelBranchName())
|
||||
rs.develBranchVersion.SetLabel(rs.pb.GetDevelBranchName())
|
||||
|
||||
rs.userWorkingName.SetText(rs.pb.GetUserBranchName())
|
||||
rs.userBranchVersion.SetLabel(rs.pb.GetUserBranchName())
|
||||
|
||||
if rs.pb.GetGoPath() == "" {
|
||||
// not golang repo
|
||||
} else {
|
||||
rs.isGoLang.SetText("true")
|
||||
rs.goPath.SetText(rs.pb.GetGoPath())
|
||||
}
|
||||
windowMap[path] = rs
|
||||
return rs, nil
|
||||
}
|
||||
|
|
74
structs.go
74
structs.go
|
@ -3,51 +3,64 @@ package repostatus
|
|||
import (
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
||||
type RepoStatus struct {
|
||||
ready bool
|
||||
hidden bool
|
||||
changed bool
|
||||
changed bool // keeps track of changes that might have happened
|
||||
changes string
|
||||
tags map[string]string
|
||||
InitOk bool // it takes a second or so to init these
|
||||
|
||||
// lasttagrev string
|
||||
tags map[string]string
|
||||
pb *gitpb.Repo // the protobuf
|
||||
|
||||
parent *gui.Node
|
||||
// used to temporarily tell the automation tools to
|
||||
// try to ignore this repo's changes and state
|
||||
// specifically when doing formal releases, sometimes
|
||||
// some repos are in flux and can't be changed. This
|
||||
// means attempt to overlook that situation.
|
||||
Whitelist bool
|
||||
|
||||
window *gadgets.BasicWindow
|
||||
window *gadgets.BasicWindow // the main window for this repo
|
||||
Tags *GitTagBox // a box of all the git tags
|
||||
|
||||
dirtyLabel *gadgets.OneLiner
|
||||
dirtyList string // the output from git status --porcelain
|
||||
readOnly *gadgets.OneLiner
|
||||
gitState *gadgets.OneLiner
|
||||
|
||||
primitive *gadgets.OneLiner // aka: doesn't have a go.sum file
|
||||
private *gadgets.OneLiner // it's not possible to publish this to pkg.go.dev
|
||||
protobuf *gadgets.OneLiner // is this repo a protobuf repo?
|
||||
|
||||
path *gadgets.OneLiner
|
||||
goSrcPath *gadgets.OneLiner
|
||||
goPath *gadgets.OneLiner
|
||||
realPath *gadgets.OneLiner
|
||||
isGoLang *gadgets.OneLiner
|
||||
|
||||
currentBranch *gadgets.OneLiner
|
||||
currentVersion *gadgets.OneLiner
|
||||
tagsDrop *gadgets.BasicDropdown
|
||||
|
||||
lasttag *gadgets.OneLiner
|
||||
masterBranchVersion *gadgets.OneLiner
|
||||
develBranchVersion *gadgets.OneLiner
|
||||
userBranchVersion *gadgets.OneLiner
|
||||
mainWorkingName *gadgets.OneLiner // the actual name of the primary branch
|
||||
develWorkingName *gadgets.OneLiner // the actual name of the devel branch
|
||||
userWorkingName *gadgets.OneLiner // the actual name of the user branch
|
||||
develMergeB *gui.Node // button to merge from user to devel
|
||||
mainMergeB *gui.Node // button to merge from devel to master
|
||||
releaseVersion *gui.Node // the release version
|
||||
minor *gadgets.BasicCombobox // the '3' in version v3.1.4
|
||||
major *gadgets.BasicCombobox // the '1' in version v3.1.4
|
||||
revision *gadgets.BasicCombobox // the '4' in version v3.1.4
|
||||
lasttag *gadgets.OneLiner // the last tag version
|
||||
mainBranchVersion *gadgets.OneLiner // the primary branch version
|
||||
develBranchVersion *gadgets.OneLiner // the devel branch version
|
||||
userBranchVersion *gadgets.OneLiner // the user branch version
|
||||
|
||||
mainWorkingName *gadgets.OneLiner
|
||||
develWorkingName *gadgets.OneLiner
|
||||
userWorkingName *gadgets.OneLiner
|
||||
|
||||
develMerge *gui.Node
|
||||
releaseVersion *gui.Node
|
||||
|
||||
// vgroup *gui.Node
|
||||
minor *gadgets.BasicCombobox
|
||||
major *gadgets.BasicCombobox
|
||||
revision *gadgets.BasicCombobox
|
||||
|
||||
versionMessage *gadgets.BasicEntry
|
||||
versionCmds [][]string
|
||||
versionCmdOutput *gadgets.OneLiner
|
||||
versionMessage *gadgets.BasicEntry
|
||||
versionCmds [][]string
|
||||
versionCmdOutput *gadgets.OneLiner
|
||||
targetReleaseVersion *gadgets.OneLiner
|
||||
|
||||
newversion *gui.Node
|
||||
|
||||
|
@ -55,10 +68,6 @@ type RepoStatus struct {
|
|||
gitStatusGroup *gui.Node
|
||||
gitCommandsGroup *gui.Node
|
||||
|
||||
masterDrop *gadgets.BasicDropdown
|
||||
develDrop *gadgets.BasicDropdown
|
||||
userDrop *gadgets.BasicDropdown
|
||||
|
||||
showBranchesButton *gui.Node
|
||||
checkBranchesButton *gui.Node
|
||||
|
||||
|
@ -66,5 +75,8 @@ type RepoStatus struct {
|
|||
speedActual *gadgets.OneLiner
|
||||
|
||||
gitConfig *GitConfig
|
||||
goConfig GoConfig
|
||||
// goConfig GoConfig
|
||||
|
||||
switchBranchB *gui.Node
|
||||
targetBranch *gui.Node
|
||||
}
|
||||
|
|
|
@ -0,0 +1,388 @@
|
|||
package repostatus
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
type Tag struct {
|
||||
// tracks if the tag is displayed
|
||||
hidden bool
|
||||
|
||||
// the tag "v0.1.3"
|
||||
tag *gui.Node
|
||||
|
||||
// the .git/ref hash
|
||||
ref *gui.Node
|
||||
|
||||
// the .git/ref date
|
||||
date *gui.Node
|
||||
duration *gui.Node
|
||||
|
||||
// the tag comment
|
||||
subject *gui.Node
|
||||
|
||||
// a button to delete the tag
|
||||
deleteB *gui.Node
|
||||
}
|
||||
|
||||
// a GUI box of all the tags in a repo
|
||||
type GitTagBox struct {
|
||||
// the box to list all the tags in
|
||||
box *gui.Node
|
||||
group *gui.Node
|
||||
grid *gui.Node
|
||||
|
||||
// all the tags
|
||||
tags []*Tag
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
|
||||
if rs.Tags != nil {
|
||||
log.Log(WARN, "already scanned tags")
|
||||
return errors.New("already scanned tags")
|
||||
}
|
||||
tagB := new(GitTagBox)
|
||||
rs.Tags = tagB
|
||||
tagB.group = box.NewGroup(".git tags for " + rs.Path())
|
||||
|
||||
// tagB.group.NewButton("prune tags", func() {
|
||||
// tagB.Prune()
|
||||
// })
|
||||
var dups *gui.Node
|
||||
|
||||
dups = tagB.group.NewCheckbox("Show duplicate tags").SetChecked(false)
|
||||
dups.Custom = func() {
|
||||
if dups.Checked() {
|
||||
tagB.Prune()
|
||||
} else {
|
||||
for _, t := range tagB.tags {
|
||||
t.Show()
|
||||
}
|
||||
}
|
||||
}
|
||||
tagB.group.NewButton("delete all", func() {
|
||||
/*
|
||||
for i, t := range tagB.tags {
|
||||
if t.hidden {
|
||||
// log.Info("tag is hidden", i, t.tag.String())
|
||||
continue
|
||||
}
|
||||
log.Info("tag is shown", i, t.tag.String())
|
||||
// rs.DeleteTag(t)
|
||||
}
|
||||
*/
|
||||
})
|
||||
|
||||
grid := tagB.group.NewGrid("tags", 0, 0)
|
||||
tagB.grid = grid
|
||||
|
||||
grid.NewLabel("version")
|
||||
grid.NewLabel("ref")
|
||||
grid.NewLabel("date")
|
||||
grid.NewLabel("release subject")
|
||||
grid.NextRow() // works like a typerwriter newline
|
||||
|
||||
loop := rs.pb.Tags.SortByAge()
|
||||
for loop.Scan() {
|
||||
tag := loop.Next()
|
||||
|
||||
rTag := new(Tag)
|
||||
rTag.tag = grid.NewLabel(tag.GetRefname())
|
||||
rTag.ref = grid.NewEntrybox(tag.GetHash())
|
||||
|
||||
ctime := tag.GetAuthordate().AsTime()
|
||||
dur := shell.GetDurationStamp(ctime)
|
||||
rTag.date = grid.NewLabel(ctime.Format("YYYY/MM/DD"))
|
||||
rTag.duration = grid.NewLabel(dur)
|
||||
|
||||
rTag.subject = grid.NewLabel(tag.GetSubject())
|
||||
rTag.deleteB = grid.NewButton("delete", func() {
|
||||
/*
|
||||
tagversion := tag.GetRefname()
|
||||
log.Info("remove tag", tagversion)
|
||||
var all [][]string
|
||||
all = append(all, []string{"git", "tag", "--delete", tagversion})
|
||||
all = append(all, []string{"git", "push", "--delete", "origin", tagversion})
|
||||
|
||||
if rs.DoAll(all) {
|
||||
log.Info("TAG DELETED", rs.Path(), tagversion)
|
||||
} else {
|
||||
log.Info("TAG DELETE FAILED", rs.Path(), tagversion)
|
||||
}
|
||||
*/
|
||||
})
|
||||
|
||||
tagB.tags = append(tagB.tags, rTag)
|
||||
// works like a typerwriter
|
||||
grid.NextRow()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rtags *GitTagBox) ListAll() []*Tag {
|
||||
var tags []*Tag
|
||||
for _, t := range rtags.tags {
|
||||
tags = append(tags, t)
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func (rtags *GitTagBox) List() []*Tag {
|
||||
var tags []*Tag
|
||||
for _, t := range rtags.tags {
|
||||
if t.hidden {
|
||||
// log.Info("tag is hidden", i, t.tag.String())
|
||||
continue
|
||||
}
|
||||
// log.Info("tag is shown", t.tag.String(), rtags.rs.String())
|
||||
tags = append(tags, t)
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func (rtags *GitTagBox) Prune() {
|
||||
dups := make(map[string]*Tag)
|
||||
for i, t := range rtags.tags {
|
||||
if t == nil {
|
||||
log.Info("tag empty:", i)
|
||||
continue
|
||||
}
|
||||
ref := t.ref.String()
|
||||
_, ok := dups[ref]
|
||||
if ok {
|
||||
log.Info("tag is duplicate:", i, t.tag.String())
|
||||
} else {
|
||||
log.Info("new tag", i, t.tag.String())
|
||||
dups[ref] = t
|
||||
t.Hide()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// hide tags worth keeping
|
||||
func (rtags *GitTagBox) PruneSmart() {
|
||||
// always keep the first tag
|
||||
var first bool = true
|
||||
|
||||
dups := make(map[string]*Tag)
|
||||
for i, t := range rtags.tags {
|
||||
if t == nil {
|
||||
log.Info("tag empty:", i)
|
||||
continue
|
||||
}
|
||||
|
||||
// check for duplicate tags
|
||||
ref := t.ref.String()
|
||||
_, ok := dups[ref]
|
||||
if ok {
|
||||
log.Info("tag is duplicate:", i, t.tag.String())
|
||||
continue
|
||||
}
|
||||
dups[ref] = t
|
||||
|
||||
// dump any tags that don't start with 'v'
|
||||
//if !strings.HasPrefix(t.tag.String(), "v") {
|
||||
// log.Info("tag does not start with v", i, t.tag.String())
|
||||
// continue
|
||||
//}
|
||||
|
||||
isVersion := regexp.MustCompile("v[0-9]+.[0-9]+.[0-9]+").MatchString
|
||||
if isVersion(t.tag.String()) {
|
||||
if first {
|
||||
log.Info("keep first tag", i, t.tag.String())
|
||||
t.Hide()
|
||||
first = false
|
||||
continue
|
||||
}
|
||||
log.Info("valid tag", i, t.tag.String())
|
||||
t.Hide()
|
||||
continue
|
||||
}
|
||||
|
||||
if first {
|
||||
log.Info("keep first tag", i, t.tag.String())
|
||||
t.Hide()
|
||||
first = false
|
||||
continue
|
||||
}
|
||||
|
||||
log.Info("keep tag", i, t.tag.String())
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// deleting it locally triggers some but when
|
||||
// the git server was uncontactable (over IPv6 if that matters, probably it doesn't)
|
||||
// and then the local delete re-added it into the tag
|
||||
func (rs *RepoStatus) DeleteTag(rt *Tag) {
|
||||
cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()}
|
||||
log.Info("RUN:", cmd)
|
||||
r := rs.Run(cmd)
|
||||
output := strings.Join(r.Stdout, "\n")
|
||||
if r.Error != nil {
|
||||
log.Info("cmd failed", r.Error)
|
||||
log.Info("output:", output)
|
||||
}
|
||||
log.Info("output:", output)
|
||||
|
||||
cmd = []string{"git", "tag", "--delete", rt.tag.String()}
|
||||
log.Info("RUN:", cmd)
|
||||
r = rs.Run(cmd)
|
||||
output = strings.Join(r.Stdout, "\n")
|
||||
if r.Error != nil {
|
||||
log.Info("cmd failed", r.Error)
|
||||
log.Info("output:", output)
|
||||
}
|
||||
log.Info("output:", output)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
func (rt *Tag) TagString() string {
|
||||
return rt.tag.String()
|
||||
}
|
||||
|
||||
func (rt *Tag) Hide() {
|
||||
rt.hidden = true
|
||||
rt.tag.Hide()
|
||||
rt.ref.Hide()
|
||||
rt.date.Hide()
|
||||
rt.duration.Hide()
|
||||
rt.subject.Hide()
|
||||
rt.deleteB.Hide()
|
||||
}
|
||||
|
||||
func (rt *Tag) Show() {
|
||||
rt.hidden = false
|
||||
rt.tag.Show()
|
||||
rt.ref.Show()
|
||||
rt.date.Show()
|
||||
rt.duration.Show()
|
||||
rt.subject.Show()
|
||||
rt.deleteB.Show()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) TagExists(findname string) bool {
|
||||
allTags := rs.Tags.ListAll()
|
||||
for _, t := range allTags {
|
||||
tagname := t.TagString()
|
||||
_, filename := filepath.Split(tagname)
|
||||
if filename == findname {
|
||||
// log.Info("found tag:", path, filename, "from", rs.Path())
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) LocalTagExists(findname string) bool {
|
||||
allTags := rs.Tags.ListAll()
|
||||
for _, t := range allTags {
|
||||
tagname := t.TagString()
|
||||
if strings.HasPrefix(tagname, "refs/remotes") {
|
||||
continue
|
||||
}
|
||||
path, filename := filepath.Split(tagname)
|
||||
log.Log(INFO, "tag:", path, filename, "from", rs.Path())
|
||||
if filename == findname {
|
||||
log.Log(INFO, "found tag:", path, filename, "from", rs.Path())
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// returns true if 'taggy' is _ONLY_ a local tag
|
||||
// this means you can not do a git pull or git push on it
|
||||
func (rs *RepoStatus) IsOnlyLocalTag(taggy string) bool {
|
||||
// first make sure the tag is actually even local
|
||||
if !rs.LocalTagExists(taggy) {
|
||||
// this means it's not even local now.
|
||||
return false
|
||||
}
|
||||
// okay, taggy exists, does it exist in a remote repo?
|
||||
for _, t := range rs.Tags.ListAll() {
|
||||
tagname := t.TagString()
|
||||
if strings.HasPrefix(tagname, "refs/remotes") {
|
||||
path, filename := filepath.Split(tagname)
|
||||
if filename == taggy {
|
||||
log.Log(REPOWARN, "found tag:", path, filename, "from", rs.Path())
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
// we couldn't find the local tag anywhere remote, so it's probably only local
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *Tag) Age() time.Duration {
|
||||
const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
|
||||
tagTime, _ := time.Parse(gitLayout, t.date.String())
|
||||
return time.Since(tagTime)
|
||||
}
|
||||
|
||||
func (t *Tag) Name() string {
|
||||
return t.tag.String()
|
||||
}
|
||||
|
||||
func (t *Tag) GetDate() (time.Time, error) {
|
||||
const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
|
||||
tagTime, err := time.Parse(gitLayout, t.date.String())
|
||||
|
||||
if err != nil {
|
||||
log.Log(REPOWARN, "tag date err", t.ref.String(), t.tag.String(), err)
|
||||
return time.Now(), err
|
||||
}
|
||||
return tagTime, nil
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) NewestTag() *Tag {
|
||||
var newest *Tag
|
||||
var newestTime time.Time
|
||||
var tagTime time.Time
|
||||
var err error
|
||||
var allTags []*Tag
|
||||
var mu sync.Mutex
|
||||
|
||||
allTags = make([]*Tag, 0, 0)
|
||||
junk := rs.Tags.ListAll()
|
||||
allTags = append(allTags, junk...)
|
||||
for _, t := range allTags {
|
||||
mu.Lock()
|
||||
if tagTime, err = t.GetDate(); err != nil {
|
||||
mu.Unlock()
|
||||
continue
|
||||
}
|
||||
|
||||
// log.Log(REPOWARN, "tag", t.ref.String(), t.date.String(), t.tag.String())
|
||||
// if this is the first tag, use it
|
||||
if newest == nil {
|
||||
newestTime = tagTime
|
||||
newest = t
|
||||
}
|
||||
|
||||
// if the tag date is after the newest date, it's newer so use this tag
|
||||
if tagTime.After(newestTime) {
|
||||
newestTime = tagTime
|
||||
newest = t
|
||||
}
|
||||
mu.Unlock()
|
||||
}
|
||||
return newest
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) DumpTags() {
|
||||
for _, t := range rs.Tags.ListAll() {
|
||||
log.Log(REPOWARN, "tag", t.ref.String(), t.date.String(), t.tag.String())
|
||||
}
|
||||
}
|
214
unix.go
214
unix.go
|
@ -1,214 +0,0 @@
|
|||
// This is a simple example
|
||||
package repostatus
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func run(path string, thing string, cmdline string) string {
|
||||
parts := strings.Split(cmdline, " ")
|
||||
// Create the command
|
||||
cmd := exec.Command(thing, parts...)
|
||||
|
||||
// Set the working directory
|
||||
cmd.Dir = path
|
||||
|
||||
// Execute the command
|
||||
output, err := cmd.CombinedOutput()
|
||||
tmp := string(output)
|
||||
tmp = strings.TrimSpace(tmp)
|
||||
|
||||
if err != nil {
|
||||
log.Log(WARN, "run()", path, thing, cmdline, "=", tmp)
|
||||
log.Error(err, "cmd error'd out", parts)
|
||||
return ""
|
||||
}
|
||||
|
||||
// Print the output
|
||||
log.Log(INFO, "run()", path, thing, cmdline, "=", tmp)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// goes in one directory so it gets remote branch names
|
||||
func listFiles(directory string) []string {
|
||||
var files []string
|
||||
fileInfo, err := os.ReadDir(directory)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, file := range fileInfo {
|
||||
if file.IsDir() {
|
||||
dirname := file.Name()
|
||||
newdir, _ := os.ReadDir(directory + "/" + dirname)
|
||||
for _, file := range newdir {
|
||||
if !file.IsDir() {
|
||||
files = append(files, dirname+"/"+file.Name())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
files = append(files, file.Name())
|
||||
}
|
||||
}
|
||||
|
||||
return files
|
||||
}
|
||||
|
||||
/*
|
||||
// string handling examples that might be helpful for normalizeInt()
|
||||
isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
|
||||
|
||||
for _, username := range []string{"userone", "user2", "user-three"} {
|
||||
if !isAlpha(username) {
|
||||
log.Log(GUI, "%q is not valid\n", username)
|
||||
}
|
||||
}
|
||||
|
||||
const alpha = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
func alphaOnly(s string) bool {
|
||||
for _, char := range s {
|
||||
if !strings.Contains(alpha, strings.ToLower(string(char))) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
*/
|
||||
|
||||
func normalizeVersion(s string) string {
|
||||
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
||||
parts := strings.Split(s, "-")
|
||||
if len(parts) == 0 {
|
||||
return ""
|
||||
}
|
||||
reg, err := regexp.Compile("[^0-9.]+")
|
||||
if err != nil {
|
||||
log.Log(WARN, "normalizeVersion() regexp.Compile() ERROR =", err)
|
||||
return parts[0]
|
||||
}
|
||||
clean := reg.ReplaceAllString(parts[0], "")
|
||||
log.Log(INFO, "normalizeVersion() s =", clean)
|
||||
return clean
|
||||
}
|
||||
|
||||
func splitVersion(version string) (a, b, c string) {
|
||||
tmp := normalizeVersion(version)
|
||||
parts := strings.Split(tmp, ".")
|
||||
switch len(parts) {
|
||||
case 1:
|
||||
return parts[0], "", ""
|
||||
case 2:
|
||||
return parts[0], parts[1], ""
|
||||
default:
|
||||
return parts[0], parts[1], parts[2]
|
||||
}
|
||||
}
|
||||
|
||||
// temp hack. fix this
|
||||
func runCmd(path string, parts []string) (error, bool, string) {
|
||||
return RunCmd(path, parts)
|
||||
}
|
||||
|
||||
func RunCmd(workingpath string, parts []string) (error, bool, string) {
|
||||
if len(parts) == 0 {
|
||||
log.Warn("command line was empty")
|
||||
return errors.New("empty"), false, ""
|
||||
}
|
||||
if parts[0] == "" {
|
||||
log.Warn("command line was empty")
|
||||
return errors.New("empty"), false, ""
|
||||
}
|
||||
thing := parts[0]
|
||||
parts = parts[1:]
|
||||
log.Log(INFO, "working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
||||
|
||||
// Create the command
|
||||
cmd := exec.Command(thing, parts...)
|
||||
|
||||
// Set the working directory
|
||||
cmd.Dir = workingpath
|
||||
|
||||
// Execute the command
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if thing == "git" {
|
||||
log.Log(INFO, "git ERROR. maybe okay", workingpath, "thing =", thing, "cmdline =", parts)
|
||||
log.Log(INFO, "git ERROR. maybe okay err =", err)
|
||||
if err.Error() == "exit status 1" {
|
||||
log.Log(INFO, "git ERROR. normal exit status 1")
|
||||
if parts[0] == "diff-index" {
|
||||
log.Log(INFO, "git normal diff-index when repo dirty")
|
||||
return nil, false, "git diff-index exit status 1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
||||
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
||||
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
||||
log.Error(err)
|
||||
log.Warn("output was", string(output))
|
||||
log.Warn("cmd exited with error", err)
|
||||
// panic("fucknuts")
|
||||
return err, false, string(output)
|
||||
}
|
||||
|
||||
tmp := string(output)
|
||||
tmp = strings.TrimSpace(tmp)
|
||||
|
||||
// Print the output
|
||||
return nil, true, tmp
|
||||
}
|
||||
|
||||
// Set the path to the package
|
||||
func getfiles(pathToPackage string) {
|
||||
// List files in the directory
|
||||
err := filepath.Walk(pathToPackage, nil) // compiles but crashes
|
||||
if err == nil {
|
||||
log.Log(INFO, "directory ok", pathToPackage)
|
||||
} else {
|
||||
log.Warn("directory wrong", pathToPackage)
|
||||
}
|
||||
}
|
||||
|
||||
func IsDirectory(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
func VerifyLocalGoRepo(gorepo string) bool {
|
||||
// Get current user
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
log.Error(err, "VerifyLocalGoRepo() thinks you should switch to Ultrix")
|
||||
return false
|
||||
}
|
||||
|
||||
// Form the path to the home Git directory
|
||||
gitDir := filepath.Join(usr.HomeDir, "go/src/", gorepo, ".git")
|
||||
|
||||
log.Log(INFO, "go directory:", gitDir)
|
||||
return IsDirectory(gitDir)
|
||||
}
|
||||
|
||||
func readFileToString(filename string) (string, error) {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimSpace(string(data)), nil
|
||||
}
|
155
update.go
155
update.go
|
@ -2,8 +2,6 @@ package repostatus
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -14,109 +12,70 @@ func (rs *RepoStatus) Update() {
|
|||
log.Error(errors.New("Update() is not ready yet"))
|
||||
return
|
||||
}
|
||||
log.Log(INFO, "Update() START")
|
||||
duration := timeFunction(func() {
|
||||
// do things that are safe even if the git tree is dirty
|
||||
// rs.path.SetValue(rs.repopath)
|
||||
rs.getCurrentBranchName()
|
||||
// rs.window.SetTitle(rs.repopath + " GO repo Details")
|
||||
rs.getCurrentBranchVersion()
|
||||
rs.getLastTagVersion()
|
||||
rs.populateTags()
|
||||
rs.CheckDirty()
|
||||
|
||||
if rs.dirtyLabel.String() != "no" {
|
||||
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String())
|
||||
rs.DisableEverything()
|
||||
rs.CheckBranches()
|
||||
return
|
||||
}
|
||||
pb := rs.pb
|
||||
|
||||
master := rs.masterDrop.String()
|
||||
devel := rs.develDrop.String()
|
||||
user := rs.userDrop.String()
|
||||
// store the current checked out branch name and version
|
||||
rs.checkCurrentBranchName()
|
||||
out := rs.pb.GetCurrentVersion()
|
||||
rs.currentVersion.SetValue(out)
|
||||
|
||||
// rs.CheckDirty() this runs
|
||||
log.Log(INFO, "checkoutBranch", master)
|
||||
rs.checkoutBranch("master", master)
|
||||
log.Log(INFO, "checkoutBranch", devel)
|
||||
rs.checkoutBranch("devel", devel)
|
||||
log.Log(INFO, "checkoutBranch", user)
|
||||
rs.checkoutBranch("user", user)
|
||||
// read in the tags
|
||||
rs.populateTags()
|
||||
|
||||
rs.recommend()
|
||||
rs.CheckBranches()
|
||||
})
|
||||
rs.setSpeed(duration)
|
||||
log.Log(INFO, "Update() END")
|
||||
// record if the repo is dirty
|
||||
pb.CheckDirty()
|
||||
|
||||
// display the last tag version
|
||||
name := rs.pb.GetLastTagVersion()
|
||||
rs.lasttag.SetText(name)
|
||||
|
||||
// store the master branch version
|
||||
ver := pb.GetMasterVersion()
|
||||
rs.mainBranchVersion.SetValue(ver)
|
||||
|
||||
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
|
||||
rs.CheckGitState()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) setSpeed(duration time.Duration) {
|
||||
s := fmt.Sprint(duration)
|
||||
if rs.speedActual == nil {
|
||||
log.Log(WARN, "rs.speedActual == nil")
|
||||
func (rs *RepoStatus) CheckGitState() string {
|
||||
rs.setState()
|
||||
return rs.gitState.String()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) setState() {
|
||||
pb := rs.pb
|
||||
rs.changed = false
|
||||
if pb.CheckDirty() {
|
||||
log.Log(REPO, "CheckDirty() true")
|
||||
rs.gitState.SetText("dirty")
|
||||
return
|
||||
}
|
||||
rs.speedActual.SetValue(s)
|
||||
|
||||
if duration > 500*time.Millisecond {
|
||||
rs.speed.SetValue("SLOW")
|
||||
} else if duration > 100*time.Millisecond {
|
||||
rs.speed.SetValue("OK")
|
||||
} else {
|
||||
rs.speed.SetValue("FAST")
|
||||
if pb.GetUserVersion() != pb.GetDevelVersion() {
|
||||
rs.gitState.SetText("merge to devel")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// disable all things besides Update() button
|
||||
func (rs *RepoStatus) DisableEverything() {
|
||||
log.Log(INFO, "DisableEverything()")
|
||||
|
||||
// choosing a major, minor or revision
|
||||
rs.major.Disable()
|
||||
rs.minor.Disable()
|
||||
rs.revision.Disable()
|
||||
|
||||
// disable adding a tag message
|
||||
rs.versionMessage.Disable()
|
||||
|
||||
// disable the merge devel to master button
|
||||
rs.develMerge.Disable()
|
||||
|
||||
// disable the tag a new version button
|
||||
rs.releaseVersion.Disable()
|
||||
}
|
||||
|
||||
// this means devel needs to be merged to master
|
||||
func (rs *RepoStatus) EnableMergeDevel() {
|
||||
rs.DisableEverything()
|
||||
|
||||
rs.develMerge.Enable()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Disable() {
|
||||
rs.window.Disable()
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) Enable() {
|
||||
rs.window.Enable()
|
||||
}
|
||||
|
||||
// this means you need to release a new version of the master repository
|
||||
func (rs *RepoStatus) EnableSelectTag() {
|
||||
rs.DisableEverything()
|
||||
|
||||
// choosing a major, minor or revision
|
||||
rs.major.Enable()
|
||||
rs.minor.Enable()
|
||||
rs.revision.Enable()
|
||||
|
||||
// disable adding a tag message
|
||||
rs.versionMessage.Enable()
|
||||
rs.versionMessage.SetText("")
|
||||
|
||||
rs.develMerge.SetLabel("ready to release")
|
||||
|
||||
// force there to be a commit message
|
||||
rs.releaseVersion.Disable()
|
||||
if pb.GetDevelVersion() != pb.GetMasterVersion() {
|
||||
rs.gitState.SetText("merge to main")
|
||||
return
|
||||
}
|
||||
if pb.GetLastTag() != pb.GetMasterVersion() {
|
||||
rs.gitState.SetText("unchanged")
|
||||
return
|
||||
}
|
||||
|
||||
if pb.CheckBranches() {
|
||||
log.Log(REPO, "Branches are Perfect")
|
||||
rs.gitState.SetText("PERFECT")
|
||||
return
|
||||
}
|
||||
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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue