lots more moved to using the protobuf
This commit is contained in:
parent
d5c394d3c3
commit
283bd90e91
57
deps.go
57
deps.go
|
@ -1,57 +0,0 @@
|
||||||
package repostatus
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (rs *RepoStatus) GetGoDeps() GoConfig {
|
|
||||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
|
||||||
gosum, err := os.Open(tmp)
|
|
||||||
if err != nil {
|
|
||||||
log.Log(REPO, "\tmissing go.sum", rs.realPath.String())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
defer gosum.Close()
|
|
||||||
|
|
||||||
var deps GoConfig
|
|
||||||
deps = make(GoConfig)
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(gosum)
|
|
||||||
log.Log(REPO, "\tgosum:", 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(REPO, "\tREPO:", rs.String(), rs.realPath.String())
|
|
||||||
log.Log(REPO, "\t version mismatch:", godep, version, currentversion)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deps[godep] = version
|
|
||||||
log.Log(REPO, "\t", godep, "=", version)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Log(REPO, "\t INVALID:", parts)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return deps
|
|
||||||
}
|
|
586
git.go
586
git.go
|
@ -44,6 +44,7 @@ func (rs *RepoStatus) Age() time.Duration {
|
||||||
var ErrorMissingGitConfig error = errors.New("missing .git/config")
|
var ErrorMissingGitConfig error = errors.New("missing .git/config")
|
||||||
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
|
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
|
||||||
|
|
||||||
|
/*
|
||||||
func (rs *RepoStatus) GitPull() (string, error) {
|
func (rs *RepoStatus) GitPull() (string, error) {
|
||||||
currentName := rs.GetCurrentBranchName()
|
currentName := rs.GetCurrentBranchName()
|
||||||
if rs.IsOnlyLocalTag(currentName) {
|
if rs.IsOnlyLocalTag(currentName) {
|
||||||
|
@ -64,286 +65,8 @@ func (rs *RepoStatus) GitPull() (string, error) {
|
||||||
}
|
}
|
||||||
return output, r.Error
|
return output, r.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// this isn't right
|
|
||||||
func (rs *RepoStatus) LastTagAge() (time.Time, string) {
|
|
||||||
return time.Now(), rs.lasttag.String()
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (rs *RepoStatus) GetLastTagVersion() string {
|
|
||||||
return rs.lasttag.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// stores the current branch name
|
|
||||||
func (rs *RepoStatus) checkCurrentBranchName() string {
|
|
||||||
currentname := rs.currentBranch.String()
|
|
||||||
out := run(rs.realPath.String(), "git", "branch --show-current")
|
|
||||||
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) gitDescribeByHash(hash string) (string, error) {
|
|
||||||
if hash == "" {
|
|
||||||
return "", errors.New("hash was blank")
|
|
||||||
}
|
|
||||||
r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always", hash}, INFO)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: don't run git every time?
|
|
||||||
func (rs *RepoStatus) checkCurrentBranchVersion() string {
|
|
||||||
out, _ := rs.gitDescribeByName("")
|
|
||||||
log.Log(REPO, "checkCurrentBranchVersion()", out)
|
|
||||||
rs.currentVersion.SetValue(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// this should get the most recent tag
|
|
||||||
func (rs *RepoStatus) setLastTagVersion() {
|
|
||||||
hash := run(rs.realPath.String(), "git", "rev-list --tags --max-count=1")
|
|
||||||
log.Log(REPO, "getLastTagVersion()", hash)
|
|
||||||
|
|
||||||
name, _ := rs.gitDescribeByHash(hash)
|
|
||||||
rs.lasttag.SetText(name)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) populateTags() {
|
|
||||||
tmp := rs.realPath.String() + "/.git/refs/tags"
|
|
||||||
log.Log(REPO, "populateTags() path =", tmp)
|
|
||||||
for _, tag := range listFiles(tmp) {
|
|
||||||
if rs.tags[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(REPO, "getBranches()", branch)
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns quickly based on the last time it was checked
|
|
||||||
func (rs *RepoStatus) IsDirty() bool {
|
|
||||||
if rs.dirtyLabel.String() == "no" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the list of dirty files (but ignores go.mod & go.sum)
|
|
||||||
func (rs *RepoStatus) DirtyList() []string {
|
|
||||||
var all []string
|
|
||||||
for _, line := range strings.Split(rs.dirtyList, "\n") {
|
|
||||||
line = strings.TrimSpace(line)
|
|
||||||
parts := strings.Split(line, " ")
|
|
||||||
if len(parts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if parts[1] == "go.mod" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if parts[1] == "go.sum" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
all = append(all, parts[1])
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) CheckDirty() bool {
|
|
||||||
var start string = rs.dirtyLabel.String()
|
|
||||||
cmd := []string{"git", "status", "--porcelain"}
|
|
||||||
r := shell.PathRunLog(rs.Path(), cmd, INFO)
|
|
||||||
out := strings.Join(r.Stdout, "\n")
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Warn("CheckDirty() status cmd =", cmd)
|
|
||||||
log.Warn("CheckDirty() status out =", out)
|
|
||||||
log.Warn("CheckDirty() status err =", r.Error)
|
|
||||||
log.Error(r.Error, "CheckDirty() git status error")
|
|
||||||
rs.dirtyLabel.SetValue("error")
|
|
||||||
if start != "error" {
|
|
||||||
rs.NoteChange("git status is in error " + fmt.Sprint(r.Error))
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.dirtyList = out
|
|
||||||
|
|
||||||
// last := out[strings.LastIndex(out, "\n")+1:]
|
|
||||||
// if last == "nothing to commit, working tree clean" {
|
|
||||||
|
|
||||||
if len(rs.DirtyList()) == 0 {
|
|
||||||
log.Log(REPO, "CheckDirty() no", rs.realPath.String())
|
|
||||||
rs.dirtyLabel.SetValue("no")
|
|
||||||
if start == "" {
|
|
||||||
// don't record a change as this is the initial run
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if start != "no" {
|
|
||||||
log.Log(REPOWARN, "is no longer dirty")
|
|
||||||
rs.NoteChange("is no longer dirty")
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.dirtyLabel.SetValue("dirty")
|
|
||||||
if start == "" {
|
|
||||||
// don't record a change as this is the initial run
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if start != "dirty" {
|
|
||||||
log.Log(REPOWARN, "is now dirty")
|
|
||||||
rs.NoteChange("is now dirty")
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
|
|
||||||
}
|
|
||||||
func (rs *RepoStatus) CheckoutBranch(bname string) bool {
|
|
||||||
if rs.CheckDirty() {
|
|
||||||
log.Log(REPO, rs.realPath.String(), "is dirty")
|
|
||||||
log.Info(bname, "is dirty", rs.Path())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if !rs.TagExists(bname) {
|
|
||||||
// tag does not exist
|
|
||||||
log.Log(REPO, "repo does not have branch", bname, rs.Path())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
cName := rs.GetCurrentBranchName()
|
|
||||||
if cName == bname {
|
|
||||||
// already on branch
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
cmd := []string{"git", "checkout", bname}
|
|
||||||
r := rs.Run(cmd)
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Log(REPO, "git checkout error:", r.Error)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
rs.checkCurrentBranchName()
|
|
||||||
rs.checkCurrentBranchVersion()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) CheckoutMaster() bool {
|
|
||||||
if rs.CheckDirty() {
|
|
||||||
log.Log(REPO, rs.realPath.String(), "is dirty")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
mName := rs.GetMasterBranchName()
|
|
||||||
if rs.CheckoutBranch(mName) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) CheckoutDevel() bool {
|
|
||||||
devel := rs.develWorkingName.String()
|
|
||||||
// user := rs.userWorkingName.String()
|
|
||||||
if devel == "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if rs.CheckDirty() {
|
|
||||||
log.Log(REPO, rs.realPath.String(), "is dirty")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Log(REPO, "checkoutBranch", devel)
|
|
||||||
rs.checkoutBranch("devel", devel)
|
|
||||||
// log.Log(REPO, "checkoutBranch", user)
|
|
||||||
// rs.checkoutBranch("user", user)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) CheckoutUser() bool {
|
|
||||||
bName := rs.GetUserBranchName()
|
|
||||||
if bName == "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if rs.CheckDirty() {
|
|
||||||
log.Log(REPO, rs.realPath.String(), "is dirty")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if !rs.BranchExists(bName) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
cmd := []string{"git", "checkout", bName}
|
|
||||||
r := rs.Run(cmd)
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Log(REPO, "git checkout error:", r.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
realname := rs.GetCurrentBranchName()
|
|
||||||
realversion := rs.GetCurrentBranchVersion()
|
|
||||||
log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
|
|
||||||
|
|
||||||
if realname != bName {
|
|
||||||
log.Log(REPO, "git checkout failed", rs.realPath.String(), bName, "!=", realname)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
rs.userBranchVersion.SetValue(realversion)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
|
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
|
||||||
if rs.CheckDirty() {
|
if rs.CheckDirty() {
|
||||||
log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
|
log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
|
||||||
|
@ -367,33 +90,6 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt's to guess at what master is.
|
|
||||||
// TODO: fix this properly
|
|
||||||
func (rs *RepoStatus) guessMainWorkingName() {
|
|
||||||
if !rs.Ready() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rs.TagExists("guimaster") {
|
|
||||||
rs.mainWorkingName.SetText("guimaster")
|
|
||||||
rs.mainBranchVersion.SetLabel("guimaster")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rs.TagExists("master") {
|
|
||||||
rs.mainWorkingName.SetText("master")
|
|
||||||
rs.mainBranchVersion.SetLabel("master")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rs.TagExists("main") {
|
|
||||||
rs.mainWorkingName.SetText("main")
|
|
||||||
rs.mainBranchVersion.SetLabel("main")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// figure out what to do here
|
|
||||||
rs.mainWorkingName.SetText("FIXME")
|
|
||||||
rs.mainBranchVersion.SetLabel("FIXME")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) guessDevelWorkingName() {
|
func (rs *RepoStatus) guessDevelWorkingName() {
|
||||||
if rs.TagExists("guidevel") {
|
if rs.TagExists("guidevel") {
|
||||||
rs.develWorkingName.SetValue("guidevel")
|
rs.develWorkingName.SetValue("guidevel")
|
||||||
|
@ -591,3 +287,283 @@ func (rs *RepoStatus) CheckBranches() bool {
|
||||||
}
|
}
|
||||||
return perfect
|
return perfect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// this isn't right
|
||||||
|
func (rs *RepoStatus) LastTagAge() (time.Time, string) {
|
||||||
|
return time.Now(), rs.lasttag.String()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (rs *RepoStatus) GetLastTagVersion() string {
|
||||||
|
return rs.lasttag.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// stores the current branch name
|
||||||
|
func (rs *RepoStatus) checkCurrentBranchName() string {
|
||||||
|
currentname := rs.currentBranch.String()
|
||||||
|
out := run(rs.realPath.String(), "git", "branch --show-current")
|
||||||
|
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) gitDescribeByHash(hash string) (string, error) {
|
||||||
|
if hash == "" {
|
||||||
|
return "", errors.New("hash was blank")
|
||||||
|
}
|
||||||
|
r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always", hash}, INFO)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: don't run git every time?
|
||||||
|
func (rs *RepoStatus) checkCurrentBranchVersion() string {
|
||||||
|
out, _ := rs.gitDescribeByName("")
|
||||||
|
log.Log(REPO, "checkCurrentBranchVersion()", out)
|
||||||
|
rs.currentVersion.SetValue(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// this should get the most recent tag
|
||||||
|
func (rs *RepoStatus) setLastTagVersion() {
|
||||||
|
hash := run(rs.realPath.String(), "git", "rev-list --tags --max-count=1")
|
||||||
|
log.Log(REPO, "getLastTagVersion()", hash)
|
||||||
|
|
||||||
|
name, _ := rs.gitDescribeByHash(hash)
|
||||||
|
rs.lasttag.SetText(name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) populateTags() {
|
||||||
|
tmp := rs.realPath.String() + "/.git/refs/tags"
|
||||||
|
log.Log(REPO, "populateTags() path =", tmp)
|
||||||
|
for _, tag := range listFiles(tmp) {
|
||||||
|
if rs.tags[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(REPO, "getBranches()", branch)
|
||||||
|
}
|
||||||
|
return all
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns quickly based on the last time it was checked
|
||||||
|
func (rs *RepoStatus) IsDirty() bool {
|
||||||
|
if rs.dirtyLabel.String() == "no" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the list of dirty files (but ignores go.mod & go.sum)
|
||||||
|
func (rs *RepoStatus) DirtyList() []string {
|
||||||
|
var all []string
|
||||||
|
for _, line := range strings.Split(rs.dirtyList, "\n") {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
parts := strings.Split(line, " ")
|
||||||
|
if len(parts) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if parts[1] == "go.mod" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if parts[1] == "go.sum" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
all = append(all, parts[1])
|
||||||
|
}
|
||||||
|
return all
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) CheckDirty() bool {
|
||||||
|
var start string = rs.dirtyLabel.String()
|
||||||
|
cmd := []string{"git", "status", "--porcelain"}
|
||||||
|
r := shell.PathRunLog(rs.Path(), cmd, INFO)
|
||||||
|
out := strings.Join(r.Stdout, "\n")
|
||||||
|
if r.Error != nil {
|
||||||
|
log.Warn("CheckDirty() status cmd =", cmd)
|
||||||
|
log.Warn("CheckDirty() status out =", out)
|
||||||
|
log.Warn("CheckDirty() status err =", r.Error)
|
||||||
|
log.Error(r.Error, "CheckDirty() git status error")
|
||||||
|
rs.dirtyLabel.SetValue("error")
|
||||||
|
if start != "error" {
|
||||||
|
rs.NoteChange("git status is in error " + fmt.Sprint(r.Error))
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.dirtyList = out
|
||||||
|
|
||||||
|
// last := out[strings.LastIndex(out, "\n")+1:]
|
||||||
|
// if last == "nothing to commit, working tree clean" {
|
||||||
|
|
||||||
|
if len(rs.DirtyList()) == 0 {
|
||||||
|
log.Log(REPO, "CheckDirty() no", rs.realPath.String())
|
||||||
|
rs.dirtyLabel.SetValue("no")
|
||||||
|
if start == "" {
|
||||||
|
// don't record a change as this is the initial run
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if start != "no" {
|
||||||
|
log.Log(REPOWARN, "is no longer dirty")
|
||||||
|
rs.NoteChange("is no longer dirty")
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.dirtyLabel.SetValue("dirty")
|
||||||
|
if start == "" {
|
||||||
|
// don't record a change as this is the initial run
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if start != "dirty" {
|
||||||
|
log.Log(REPOWARN, "is now dirty")
|
||||||
|
rs.NoteChange("is now dirty")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) CheckoutBranch(bname string) bool {
|
||||||
|
if rs.CheckDirty() {
|
||||||
|
log.Log(REPO, rs.realPath.String(), "is dirty")
|
||||||
|
log.Info(bname, "is dirty", rs.Path())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !rs.TagExists(bname) {
|
||||||
|
// tag does not exist
|
||||||
|
log.Log(REPO, "repo does not have branch", bname, rs.Path())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
cName := rs.GetCurrentBranchName()
|
||||||
|
if cName == bname {
|
||||||
|
// already on branch
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
cmd := []string{"git", "checkout", bname}
|
||||||
|
r := rs.Run(cmd)
|
||||||
|
if r.Error != nil {
|
||||||
|
log.Log(REPO, "git checkout error:", r.Error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
rs.checkCurrentBranchName()
|
||||||
|
rs.checkCurrentBranchVersion()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) CheckoutMaster() bool {
|
||||||
|
if rs.CheckDirty() {
|
||||||
|
log.Log(REPO, rs.realPath.String(), "is dirty")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
mName := rs.GetMasterBranchName()
|
||||||
|
if rs.CheckoutBranch(mName) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) CheckoutDevel() bool {
|
||||||
|
devel := rs.develWorkingName.String()
|
||||||
|
// user := rs.userWorkingName.String()
|
||||||
|
if devel == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if rs.CheckDirty() {
|
||||||
|
log.Log(REPO, rs.realPath.String(), "is dirty")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Log(REPO, "checkoutBranch", devel)
|
||||||
|
rs.checkoutBranch("devel", devel)
|
||||||
|
// log.Log(REPO, "checkoutBranch", user)
|
||||||
|
// rs.checkoutBranch("user", user)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RepoStatus) CheckoutUser() bool {
|
||||||
|
bName := rs.GetUserBranchName()
|
||||||
|
if bName == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if rs.CheckDirty() {
|
||||||
|
log.Log(REPO, rs.realPath.String(), "is dirty")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !rs.BranchExists(bName) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
cmd := []string{"git", "checkout", bName}
|
||||||
|
r := rs.Run(cmd)
|
||||||
|
if r.Error != nil {
|
||||||
|
log.Log(REPO, "git checkout error:", r.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
realname := rs.GetCurrentBranchName()
|
||||||
|
realversion := rs.GetCurrentBranchVersion()
|
||||||
|
log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
|
||||||
|
|
||||||
|
if realname != bName {
|
||||||
|
log.Log(REPO, "git checkout failed", rs.realPath.String(), bName, "!=", realname)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
rs.userBranchVersion.SetValue(realversion)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -32,7 +33,7 @@ type GitConfig struct {
|
||||||
versions map[string]string
|
versions map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoConfig map[string]string
|
// type GoConfig map[string]string
|
||||||
|
|
||||||
func ListGitDirectories() []string {
|
func ListGitDirectories() []string {
|
||||||
var all []string
|
var all []string
|
||||||
|
@ -253,11 +254,13 @@ func (rs *RepoStatus) processBranch(branch string) {
|
||||||
hash, ok := rs.gitConfig.hashes[branch]
|
hash, ok := rs.gitConfig.hashes[branch]
|
||||||
filename := fullpath + "/.git/refs/heads/" + branch
|
filename := fullpath + "/.git/refs/heads/" + branch
|
||||||
log.Log(INFO, " hash: need to open", filename)
|
log.Log(INFO, " hash: need to open", filename)
|
||||||
newhash, err := readFileToString(filename)
|
|
||||||
|
data, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log(WARN, "hash: read failed", filename, rs.String())
|
log.Log(WARN, "hash: read failed", filename, rs.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
newhash := strings.TrimSpace(string(data))
|
||||||
log.Log(INFO, " hash:", newhash)
|
log.Log(INFO, " hash:", newhash)
|
||||||
rs.gitConfig.hashes[branch] = newhash
|
rs.gitConfig.hashes[branch] = newhash
|
||||||
if ok {
|
if ok {
|
||||||
|
|
41
goConfig.go
41
goConfig.go
|
@ -3,48 +3,10 @@ package repostatus
|
||||||
// does processing on the go.mod and go.sum files
|
// does processing on the go.mod and go.sum files
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Detect a 'Primative' package. Sets the isPrimative flag
|
/*
|
||||||
// will return true if the repo is truly not dependent on _anything_ else
|
|
||||||
// like spew or lib/widget
|
|
||||||
// it assumes go mod ran init and tidy ran without error
|
|
||||||
func (rs *RepoStatus) isPrimativeGoMod() (bool, error) {
|
|
||||||
// go mod init & go mod tidy ran without errors
|
|
||||||
log.Log(REPO, "isPrimativeGoMod()", rs.realPath.String())
|
|
||||||
tmp := filepath.Join(rs.realPath.String(), "go.mod")
|
|
||||||
gomod, err := os.Open(tmp)
|
|
||||||
if err != nil {
|
|
||||||
log.Log(REPO, "missing go.mod", rs.realPath.String())
|
|
||||||
rs.goConfig = nil
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
defer gomod.Close()
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(gomod)
|
|
||||||
for scanner.Scan() {
|
|
||||||
line := strings.TrimSpace(scanner.Text())
|
|
||||||
|
|
||||||
parts := strings.Split(line, " ")
|
|
||||||
log.Log(REPO, " gomod:", parts)
|
|
||||||
if len(parts) >= 1 {
|
|
||||||
log.Log(REPO, " gomod: part[0] =", parts[0])
|
|
||||||
if parts[0] == "require" {
|
|
||||||
log.Log(REPO, " should return false here")
|
|
||||||
return false, errors.New("go.mod file is not primative")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// readGoMod reads and parses the go.sum file
|
// readGoMod reads and parses the go.sum file
|
||||||
// saves the config information in *Repo.goConfig
|
// saves the config information in *Repo.goConfig
|
||||||
|
@ -105,6 +67,7 @@ func (rs *RepoStatus) parseGoSum() (bool, error) {
|
||||||
func (rs *RepoStatus) GoConfig() map[string]string {
|
func (rs *RepoStatus) GoConfig() map[string]string {
|
||||||
return rs.goConfig
|
return rs.goConfig
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// for now, even check cmd.Exit
|
// for now, even check cmd.Exit
|
||||||
func (rs *RepoStatus) strictRun(cmd []string) (bool, error) {
|
func (rs *RepoStatus) strictRun(cmd []string) (bool, error) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
newgrid.NewButton("git pull", func() {
|
newgrid.NewButton("git pull", func() {
|
||||||
rs.GitPull()
|
rs.pb.GitPull()
|
||||||
})
|
})
|
||||||
newgrid.NextRow()
|
newgrid.NextRow()
|
||||||
|
|
||||||
|
|
41
new.go
41
new.go
|
@ -2,7 +2,6 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
@ -41,10 +40,6 @@ func SetWorkPath(path string) {
|
||||||
// it's doesn't need to be displayed so it'll work fine even in an embedded space
|
// 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) {
|
func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
|
||||||
path := repo.GoPath
|
path := repo.GoPath
|
||||||
goSrcDir := os.Getenv("FORGE_GOSRC")
|
|
||||||
realpath := repo.FullPath
|
|
||||||
isGoLang := true
|
|
||||||
|
|
||||||
if windowMap[path] == nil {
|
if windowMap[path] == nil {
|
||||||
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,6 +51,9 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
|
||||||
rs := &RepoStatus{
|
rs := &RepoStatus{
|
||||||
ready: false,
|
ready: false,
|
||||||
}
|
}
|
||||||
|
rs.pb = repo
|
||||||
|
// realpath := repo.FullPath
|
||||||
|
// isGoLang := true
|
||||||
|
|
||||||
rs.tags = make(map[string]string)
|
rs.tags = make(map[string]string)
|
||||||
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
||||||
|
@ -83,34 +81,33 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
|
||||||
|
|
||||||
// save ~/go/src & the whole path strings
|
// save ~/go/src & the whole path strings
|
||||||
rs.path.SetValue(path)
|
rs.path.SetValue(path)
|
||||||
rs.goSrcPath.SetValue(goSrcDir)
|
rs.goSrcPath.SetValue(os.Getenv("FORGE_GOSRC"))
|
||||||
rs.realPath.SetValue(realpath)
|
rs.realPath.SetValue(rs.pb.GetFullPath())
|
||||||
|
|
||||||
// add all the tags
|
// add all the tags
|
||||||
rs.makeTagBox(box2)
|
rs.makeTagBox(box2)
|
||||||
|
|
||||||
rs.readGitConfig()
|
rs.readGitConfig()
|
||||||
|
|
||||||
rs.readOnly.SetValue("true")
|
if rs.pb.GetReadOnly() {
|
||||||
// ignore everything else for now
|
rs.readOnly.SetValue("true")
|
||||||
// todo: move this logic to cfgfile.go
|
} else {
|
||||||
if strings.HasPrefix(path, "go.wit.com") {
|
|
||||||
rs.readOnly.SetValue("false")
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(path, "git.wit.org") {
|
|
||||||
rs.readOnly.SetValue("false")
|
rs.readOnly.SetValue("false")
|
||||||
}
|
}
|
||||||
|
rs.mainWorkingName.SetText(rs.pb.GetMasterBranchName())
|
||||||
|
rs.mainBranchVersion.SetLabel(rs.pb.GetMasterBranchName())
|
||||||
|
|
||||||
// tries 'master', 'main', etc.
|
rs.develWorkingName.SetText(rs.pb.GetDevelBranchName())
|
||||||
rs.guessMainWorkingName()
|
rs.develBranchVersion.SetLabel(rs.pb.GetDevelBranchName())
|
||||||
// tries 'devel', etc
|
|
||||||
rs.guessDevelWorkingName()
|
|
||||||
// sets this to os.Username
|
|
||||||
rs.setUserWorkingName()
|
|
||||||
|
|
||||||
if isGoLang {
|
rs.userWorkingName.SetText(rs.pb.GetUserBranchName())
|
||||||
|
rs.userBranchVersion.SetLabel(rs.pb.GetUserBranchName())
|
||||||
|
|
||||||
|
if rs.pb.GoPath == "" {
|
||||||
|
// not golang repo
|
||||||
|
} else {
|
||||||
rs.isGoLang.SetText("true")
|
rs.isGoLang.SetText("true")
|
||||||
rs.goPath.SetText(path)
|
rs.goPath.SetText(rs.pb.GoPath)
|
||||||
}
|
}
|
||||||
windowMap[path] = rs
|
windowMap[path] = rs
|
||||||
return rs, nil
|
return rs, nil
|
||||||
|
|
|
@ -3,6 +3,7 @@ package repostatus
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RepoStatus struct {
|
type RepoStatus struct {
|
||||||
|
@ -12,6 +13,8 @@ type RepoStatus struct {
|
||||||
tags map[string]string
|
tags map[string]string
|
||||||
InitOk bool // it takes a second or so to init these
|
InitOk bool // it takes a second or so to init these
|
||||||
|
|
||||||
|
pb *gitpb.Repo // the protobuf
|
||||||
|
|
||||||
// used to temporarily tell the automation tools to
|
// used to temporarily tell the automation tools to
|
||||||
// try to ignore this repo's changes and state
|
// try to ignore this repo's changes and state
|
||||||
// specifically when doing formal releases, sometimes
|
// specifically when doing formal releases, sometimes
|
||||||
|
@ -72,7 +75,7 @@ type RepoStatus struct {
|
||||||
speedActual *gadgets.OneLiner
|
speedActual *gadgets.OneLiner
|
||||||
|
|
||||||
gitConfig *GitConfig
|
gitConfig *GitConfig
|
||||||
goConfig GoConfig
|
// goConfig GoConfig
|
||||||
|
|
||||||
switchBranchB *gui.Node
|
switchBranchB *gui.Node
|
||||||
targetBranch *gui.Node
|
targetBranch *gui.Node
|
||||||
|
|
51
tagWindow.go
51
tagWindow.go
|
@ -4,13 +4,11 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -88,49 +86,24 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
|
||||||
grid.NewLabel("ref")
|
grid.NewLabel("ref")
|
||||||
grid.NewLabel("date")
|
grid.NewLabel("date")
|
||||||
grid.NewLabel("release subject")
|
grid.NewLabel("release subject")
|
||||||
// works like a typerwriter
|
grid.NextRow() // works like a typerwriter newline
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
// git tag --list --sort=taggerdate
|
loop := rs.pb.Tags.SortByAge()
|
||||||
// git for-each-ref --sort=taggerdate --format '%(tag) %(*objectname) %(taggerdate)'
|
for loop.Scan() {
|
||||||
// git rev-parse HEAD
|
tag := loop.Next()
|
||||||
// if last tag == HEAD, then remove it
|
|
||||||
|
|
||||||
tags := []string{"%(objectname)", "%(creatordate)", "%(*authordate)", "%(refname)", "%(subject)"}
|
|
||||||
format := strings.Join(tags, "_,,,_")
|
|
||||||
cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format}
|
|
||||||
// log.Info("RUNNING:", strings.Join(cmd, " "))
|
|
||||||
r := shell.PathRunQuiet(rs.Path(), cmd)
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Warn("git for-each-ref error:", r.Error)
|
|
||||||
return r.Error
|
|
||||||
}
|
|
||||||
|
|
||||||
lines := r.Stdout
|
|
||||||
// reverse the git order
|
|
||||||
slices.Reverse(lines)
|
|
||||||
tagB.tags = make([]*Tag, 0)
|
|
||||||
|
|
||||||
for i, line := range lines {
|
|
||||||
var parts []string
|
|
||||||
parts = make([]string, 0)
|
|
||||||
parts = strings.Split(line, "_,,,_")
|
|
||||||
if len(parts) != 5 {
|
|
||||||
log.Info("tag error:", i, parts)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// log.Info("found tag:", i, parts)
|
|
||||||
rTag := new(Tag)
|
rTag := new(Tag)
|
||||||
rTag.tag = grid.NewLabel(parts[3])
|
rTag.tag = grid.NewLabel(tag.GetRefname())
|
||||||
rTag.ref = grid.NewEntrybox(parts[0])
|
rTag.ref = grid.NewEntrybox(tag.GetHash())
|
||||||
|
|
||||||
_, stamp, dur := getGitDateStamp(parts[1])
|
ctime := tag.GetAuthordate().AsTime()
|
||||||
rTag.date = grid.NewLabel(stamp)
|
dur := getDurationStamp(ctime)
|
||||||
|
rTag.date = grid.NewLabel(ctime.Format("YYYY/MM/DD"))
|
||||||
rTag.duration = grid.NewLabel(dur)
|
rTag.duration = grid.NewLabel(dur)
|
||||||
|
|
||||||
rTag.subject = grid.NewLabel(parts[4])
|
rTag.subject = grid.NewLabel(tag.GetSubject())
|
||||||
rTag.deleteB = grid.NewButton("delete", func() {
|
rTag.deleteB = grid.NewButton("delete", func() {
|
||||||
tagversion := parts[0]
|
tagversion := tag.GetRefname()
|
||||||
log.Info("remove tag", tagversion)
|
log.Info("remove tag", tagversion)
|
||||||
var all [][]string
|
var all [][]string
|
||||||
all = append(all, []string{"git", "tag", "--delete", tagversion})
|
all = append(all, []string{"git", "tag", "--delete", tagversion})
|
||||||
|
@ -147,8 +120,6 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
|
||||||
// works like a typerwriter
|
// works like a typerwriter
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
}
|
}
|
||||||
// reverse the git order
|
|
||||||
// slices.Reverse(rtags.tags)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
unix.go
6
unix.go
|
@ -2,12 +2,10 @@ package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -179,6 +177,7 @@ func Exists(file string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func readFileToString(filename string) (string, error) {
|
func readFileToString(filename string) (string, error) {
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -217,6 +216,7 @@ func getRawDateStamp(raw string) (time.Time, string, string) {
|
||||||
gitTagDate := time.Unix(i, 0)
|
gitTagDate := time.Unix(i, 0)
|
||||||
return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
|
return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func getDurationStamp(t time.Time) string {
|
func getDurationStamp(t time.Time) string {
|
||||||
|
|
||||||
|
@ -376,6 +376,7 @@ func (rs *RepoStatus) DoAll(all [][]string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func ScanGitDirectories(srcDir string) []string {
|
func ScanGitDirectories(srcDir string) []string {
|
||||||
var all []string
|
var all []string
|
||||||
err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
|
err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
|
||||||
|
@ -398,3 +399,4 @@ func ScanGitDirectories(srcDir string) []string {
|
||||||
|
|
||||||
return all
|
return all
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue