summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-03 00:34:55 -0600
committerJeff Carr <[email protected]>2024-12-03 00:34:55 -0600
commit283bd90e91d22e107cff71fcc613b8d646784aba (patch)
treeff26af5a12c12685f42c713b164b62e35402631b
parentd5c394d3c3894a141d5848483102433a30e1a2db (diff)
lots more moved to using the protobufv0.22.24v0.22.23
-rw-r--r--deps.go57
-rw-r--r--git.go472
-rw-r--r--gitConfig.go7
-rw-r--r--goConfig.go41
-rw-r--r--modifyBox.go2
-rw-r--r--new.go41
-rw-r--r--structs.go5
-rw-r--r--tagWindow.go51
-rw-r--r--unix.go6
9 files changed, 270 insertions, 412 deletions
diff --git a/deps.go b/deps.go
deleted file mode 100644
index 5fb2265..0000000
--- a/deps.go
+++ /dev/null
@@ -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
-}
diff --git a/git.go b/git.go
index cef5d05..42255f0 100644
--- a/git.go
+++ b/git.go
@@ -44,6 +44,7 @@ func (rs *RepoStatus) Age() time.Duration {
var ErrorMissingGitConfig error = errors.New("missing .git/config")
var ErrorGitPullOnLocal error = errors.New("git pull on local only branch")
+/*
func (rs *RepoStatus) GitPull() (string, error) {
currentName := rs.GetCurrentBranchName()
if rs.IsOnlyLocalTag(currentName) {
@@ -64,6 +65,228 @@ func (rs *RepoStatus) GitPull() (string, error) {
}
return output, r.Error
}
+*/
+
+func (rs *RepoStatus) checkoutBranch(level string, branch string) {
+ if rs.CheckDirty() {
+ log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
+ return
+ }
+ out := run(rs.realPath.String(), "git", "checkout "+branch)
+ log.Log(REPO, rs.realPath.String(), "git checkout "+branch, "returned", out)
+
+ realname := rs.GetCurrentBranchName()
+ realversion := rs.GetCurrentBranchVersion()
+ log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
+
+ switch level {
+ case "master":
+ rs.mainBranchVersion.SetValue(realversion)
+ case "devel":
+ rs.develBranchVersion.SetValue(realversion)
+ case "user":
+ rs.userBranchVersion.SetValue(realversion)
+ default:
+ }
+}
+
+func (rs *RepoStatus) guessDevelWorkingName() {
+ if rs.TagExists("guidevel") {
+ rs.develWorkingName.SetValue("guidevel")
+ rs.develBranchVersion.SetLabel("guidevel")
+ return
+ }
+ if rs.TagExists("devel") {
+ rs.develWorkingName.SetValue("devel")
+ rs.develBranchVersion.SetLabel("devel")
+ return
+ }
+
+ // figure out what to do here
+ rs.develWorkingName.SetValue("develFIXME")
+ rs.develBranchVersion.SetLabel("develFIXME")
+}
+
+func (rs *RepoStatus) setUserWorkingName() {
+ usr, _ := user.Current()
+ uname := usr.Username
+ if rs.TagExists(uname) {
+ rs.userWorkingName.SetValue(uname)
+ rs.userBranchVersion.SetLabel(uname)
+ return
+ }
+ rs.userWorkingName.SetValue("need to create " + uname)
+ rs.userBranchVersion.SetLabel("need to create " + uname)
+}
+
+// returns "master", "devel", os.Username, etc
+func (rs *RepoStatus) GetMasterBranchName() string {
+ name := rs.mainWorkingName.String()
+ return name
+}
+func (rs *RepoStatus) GetDevelBranchName() string {
+ name := rs.develWorkingName.String()
+ return name
+}
+
+func (rs *RepoStatus) GetUserBranchName() string {
+ name := rs.userWorkingName.String()
+ return name
+}
+
+// returns the git versions like "1.3-2-laksdjf" or whatever
+func (rs *RepoStatus) GetMasterVersion() string {
+ name := rs.mainBranchVersion.String()
+ return name
+}
+func (rs *RepoStatus) GetDevelVersion() string {
+ name := rs.develBranchVersion.String()
+ return name
+}
+func (rs *RepoStatus) GetUserVersion() string {
+ name := rs.userBranchVersion.String()
+ return name
+}
+
+func (rs *RepoStatus) setMasterVersion(s string) {
+ old := rs.GetMasterVersion()
+ if old == s {
+ return
+ }
+ rs.mainBranchVersion.SetValue(s)
+ if old == "" {
+ return // don't note if there was nothing before
+ }
+ rs.NoteChange("master branch has been changed from " + old + " to " + s)
+}
+
+func (rs *RepoStatus) setDevelVersion(s string) {
+ old := rs.GetDevelVersion()
+ if old == s {
+ return
+ }
+ if old == "" {
+ // don't note nothing
+ } else {
+ rs.NoteChange("devel branch has been changed from " + old + " to " + s)
+ }
+ rs.develBranchVersion.SetValue(s)
+}
+
+func (rs *RepoStatus) setUserVersion(s string) {
+ old := rs.GetUserVersion()
+ if old == s {
+ return
+ }
+ if old == "" {
+ // don't note nothing
+ } else {
+ rs.NoteChange("user branch has been changed from " + old + " to " + s)
+ }
+ rs.userBranchVersion.SetValue(s)
+}
+
+func (rs *RepoStatus) GitState() string {
+ return rs.gitState.String()
+}
+
+func (rs *RepoStatus) CheckGitState() string {
+ rs.setState()
+ return rs.gitState.String()
+}
+
+func (rs *RepoStatus) GetStatus() string {
+ return rs.gitState.String()
+}
+
+func (rs *RepoStatus) setState() {
+ rs.changed = false
+ if rs.CheckDirty() {
+ log.Log(REPO, "CheckDirty() true")
+ rs.gitState.SetText("dirty")
+ return
+ }
+ if rs.GetUserVersion() != rs.GetDevelVersion() {
+ rs.gitState.SetText("merge to devel")
+ return
+ }
+ if rs.GetDevelVersion() != rs.GetMasterVersion() {
+ rs.gitState.SetText("merge to main")
+ return
+ }
+ if rs.lasttag.String() != rs.GetMasterVersion() {
+ rs.gitState.SetText("unchanged")
+ return
+ }
+
+ if rs.CheckBranches() {
+ log.Log(REPO, "Branches are Perfect")
+ rs.gitState.SetText("PERFECT")
+ return
+ }
+ log.Log(REPO, rs.String(), "Branches are not Perfect")
+ rs.gitState.SetText("unknown branches")
+}
+
+// TODO: make this report the error somewhere
+// This is supposed to check all the branches to make sure
+// the are the same. that was originally what this was for
+// now I think it's jsut probably dumb old code that doesn't
+// need to be here
+
+// actually, this is to attempt to verify absolutely everything
+// is pushed upstream before doing a rm -rf ~/go/src
+// TODO: revisit this code in the autotypist later
+func (rs *RepoStatus) CheckBranches() bool {
+ var hashCheck string
+ var perfect bool = true
+ all := rs.getBranches()
+ path := rs.realPath.String() + "/.git/refs/"
+ for _, b := range all {
+ parts := strings.Split(b, "/")
+ rdir := "heads"
+ if len(parts) == 2 {
+ rdir = "remotes"
+ }
+ fullfile := path + "/" + rdir + "/" + b
+
+ // check if the ref name is "HEAD". if so, skip
+ runeCount := utf8.RuneCountInString(fullfile)
+ // Convert the string to a slice of runes
+ runes := []rune(fullfile)
+ // Slice the last 4 runes
+ lastFour := runes[runeCount-4:]
+ if string(lastFour) == "HEAD" {
+ log.Log(REPO, "skip HEAD fullfile", fullfile)
+ continue
+ }
+
+ content, _ := ioutil.ReadFile(fullfile)
+ hash := strings.TrimSpace(string(content))
+ if hashCheck == "" {
+ hashCheck = hash
+ }
+ var cmd []string
+ cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash)
+ r := shell.PathRunLog(rs.Path(), cmd, INFO)
+ if r.Error != nil {
+ log.Log(WARN, "CheckBranches() git show error:", r.Error)
+ }
+ // git show -s --format=%ci <hash> will give you the time
+ // log.Log(REPO, fullfile)
+ if hash == hashCheck {
+ log.Log(REPO, "notsure why this git show is here", hash)
+ } else {
+ // log.Log(WARN, rs.String(), hash, output, b)
+ // log.Log(WARN, "UNKNOWN BRANCHES IN THIS REPO", cmd)
+ rs.versionCmdOutput.SetText("UNKNOWN BRANCHES")
+ perfect = false
+ // parts := strings.Split(b, "/")
+ // log.Warn("git push", parts)
+ }
+ }
+ return perfect
+}
/*
// this isn't right
@@ -257,6 +480,7 @@ func (rs *RepoStatus) CheckDirty() bool {
return true
}
+
func (rs *RepoStatus) CheckoutBranch(bname string) bool {
if rs.CheckDirty() {
log.Log(REPO, rs.realPath.String(), "is dirty")
@@ -343,251 +567,3 @@ func (rs *RepoStatus) CheckoutUser() bool {
rs.userBranchVersion.SetValue(realversion)
return true
}
-
-func (rs *RepoStatus) checkoutBranch(level string, branch string) {
- if rs.CheckDirty() {
- log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch)
- return
- }
- out := run(rs.realPath.String(), "git", "checkout "+branch)
- log.Log(REPO, rs.realPath.String(), "git checkout "+branch, "returned", out)
-
- realname := rs.GetCurrentBranchName()
- realversion := rs.GetCurrentBranchVersion()
- log.Log(REPO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
-
- switch level {
- case "master":
- rs.mainBranchVersion.SetValue(realversion)
- case "devel":
- rs.develBranchVersion.SetValue(realversion)
- case "user":
- rs.userBranchVersion.SetValue(realversion)
- default:
- }
-}
-
-// 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() {
- if rs.TagExists("guidevel") {
- rs.develWorkingName.SetValue("guidevel")
- rs.develBranchVersion.SetLabel("guidevel")
- return
- }
- if rs.TagExists("devel") {
- rs.develWorkingName.SetValue("devel")
- rs.develBranchVersion.SetLabel("devel")
- return
- }
-
- // figure out what to do here
- rs.develWorkingName.SetValue("develFIXME")
- rs.develBranchVersion.SetLabel("develFIXME")
-}
-
-func (rs *RepoStatus) setUserWorkingName() {
- usr, _ := user.Current()
- uname := usr.Username
- if rs.TagExists(uname) {
- rs.userWorkingName.SetValue(uname)
- rs.userBranchVersion.SetLabel(uname)
- return
- }
- rs.userWorkingName.SetValue("need to create " + uname)
- rs.userBranchVersion.SetLabel("need to create " + uname)
-}
-
-// returns "master", "devel", os.Username, etc
-func (rs *RepoStatus) GetMasterBranchName() string {
- name := rs.mainWorkingName.String()
- return name
-}
-func (rs *RepoStatus) GetDevelBranchName() string {
- name := rs.develWorkingName.String()
- return name
-}
-
-func (rs *RepoStatus) GetUserBranchName() string {
- name := rs.userWorkingName.String()
- return name
-}
-
-// returns the git versions like "1.3-2-laksdjf" or whatever
-func (rs *RepoStatus) GetMasterVersion() string {
- name := rs.mainBranchVersion.String()
- return name
-}
-func (rs *RepoStatus) GetDevelVersion() string {
- name := rs.develBranchVersion.String()
- return name
-}
-func (rs *RepoStatus) GetUserVersion() string {
- name := rs.userBranchVersion.String()
- return name
-}
-
-func (rs *RepoStatus) setMasterVersion(s string) {
- old := rs.GetMasterVersion()
- if old == s {
- return
- }
- rs.mainBranchVersion.SetValue(s)
- if old == "" {
- return // don't note if there was nothing before
- }
- rs.NoteChange("master branch has been changed from " + old + " to " + s)
-}
-
-func (rs *RepoStatus) setDevelVersion(s string) {
- old := rs.GetDevelVersion()
- if old == s {
- return
- }
- if old == "" {
- // don't note nothing
- } else {
- rs.NoteChange("devel branch has been changed from " + old + " to " + s)
- }
- rs.develBranchVersion.SetValue(s)
-}
-
-func (rs *RepoStatus) setUserVersion(s string) {
- old := rs.GetUserVersion()
- if old == s {
- return
- }
- if old == "" {
- // don't note nothing
- } else {
- rs.NoteChange("user branch has been changed from " + old + " to " + s)
- }
- rs.userBranchVersion.SetValue(s)
-}
-
-func (rs *RepoStatus) GitState() string {
- return rs.gitState.String()
-}
-
-func (rs *RepoStatus) CheckGitState() string {
- rs.setState()
- return rs.gitState.String()
-}
-
-func (rs *RepoStatus) GetStatus() string {
- return rs.gitState.String()
-}
-
-func (rs *RepoStatus) setState() {
- rs.changed = false
- if rs.CheckDirty() {
- log.Log(REPO, "CheckDirty() true")
- rs.gitState.SetText("dirty")
- return
- }
- if rs.GetUserVersion() != rs.GetDevelVersion() {
- rs.gitState.SetText("merge to devel")
- return
- }
- if rs.GetDevelVersion() != rs.GetMasterVersion() {
- rs.gitState.SetText("merge to main")
- return
- }
- if rs.lasttag.String() != rs.GetMasterVersion() {
- rs.gitState.SetText("unchanged")
- return
- }
-
- if rs.CheckBranches() {
- log.Log(REPO, "Branches are Perfect")
- rs.gitState.SetText("PERFECT")
- return
- }
- log.Log(REPO, rs.String(), "Branches are not Perfect")
- rs.gitState.SetText("unknown branches")
-}
-
-// TODO: make this report the error somewhere
-// This is supposed to check all the branches to make sure
-// the are the same. that was originally what this was for
-// now I think it's jsut probably dumb old code that doesn't
-// need to be here
-
-// actually, this is to attempt to verify absolutely everything
-// is pushed upstream before doing a rm -rf ~/go/src
-// TODO: revisit this code in the autotypist later
-func (rs *RepoStatus) CheckBranches() bool {
- var hashCheck string
- var perfect bool = true
- all := rs.getBranches()
- path := rs.realPath.String() + "/.git/refs/"
- for _, b := range all {
- parts := strings.Split(b, "/")
- rdir := "heads"
- if len(parts) == 2 {
- rdir = "remotes"
- }
- fullfile := path + "/" + rdir + "/" + b
-
- // check if the ref name is "HEAD". if so, skip
- runeCount := utf8.RuneCountInString(fullfile)
- // Convert the string to a slice of runes
- runes := []rune(fullfile)
- // Slice the last 4 runes
- lastFour := runes[runeCount-4:]
- if string(lastFour) == "HEAD" {
- log.Log(REPO, "skip HEAD fullfile", fullfile)
- continue
- }
-
- content, _ := ioutil.ReadFile(fullfile)
- hash := strings.TrimSpace(string(content))
- if hashCheck == "" {
- hashCheck = hash
- }
- var cmd []string
- cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash)
- r := shell.PathRunLog(rs.Path(), cmd, INFO)
- if r.Error != nil {
- log.Log(WARN, "CheckBranches() git show error:", r.Error)
- }
- // git show -s --format=%ci <hash> will give you the time
- // log.Log(REPO, fullfile)
- if hash == hashCheck {
- log.Log(REPO, "notsure why this git show is here", hash)
- } else {
- // log.Log(WARN, rs.String(), hash, output, b)
- // log.Log(WARN, "UNKNOWN BRANCHES IN THIS REPO", cmd)
- rs.versionCmdOutput.SetText("UNKNOWN BRANCHES")
- perfect = false
- // parts := strings.Split(b, "/")
- // log.Warn("git push", parts)
- }
- }
- return perfect
-}
diff --git a/gitConfig.go b/gitConfig.go
index 389b028..e8c4c4b 100644
--- a/gitConfig.go
+++ b/gitConfig.go
@@ -2,6 +2,7 @@ package repostatus
import (
"bufio"
+ "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -32,7 +33,7 @@ type GitConfig struct {
versions map[string]string
}
-type GoConfig map[string]string
+// type GoConfig map[string]string
func ListGitDirectories() []string {
var all []string
@@ -253,11 +254,13 @@ func (rs *RepoStatus) processBranch(branch string) {
hash, ok := rs.gitConfig.hashes[branch]
filename := fullpath + "/.git/refs/heads/" + branch
log.Log(INFO, " hash: need to open", filename)
- newhash, err := readFileToString(filename)
+
+ data, err := ioutil.ReadFile(filename)
if err != nil {
log.Log(WARN, "hash: read failed", filename, rs.String())
return
}
+ newhash := strings.TrimSpace(string(data))
log.Log(INFO, " hash:", newhash)
rs.gitConfig.hashes[branch] = newhash
if ok {
diff --git a/goConfig.go b/goConfig.go
index 6f34cba..c29e787 100644
--- a/goConfig.go
+++ b/goConfig.go
@@ -3,48 +3,10 @@ package repostatus
// does processing on the go.mod and go.sum files
import (
- "bufio"
- "errors"
- "os"
- "path/filepath"
- "strings"
-
"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
// saves the config information in *Repo.goConfig
@@ -105,6 +67,7 @@ func (rs *RepoStatus) parseGoSum() (bool, error) {
func (rs *RepoStatus) GoConfig() map[string]string {
return rs.goConfig
}
+*/
// for now, even check cmd.Exit
func (rs *RepoStatus) strictRun(cmd []string) (bool, error) {
diff --git a/modifyBox.go b/modifyBox.go
index 5b9d030..644fcda 100644
--- a/modifyBox.go
+++ b/modifyBox.go
@@ -40,7 +40,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
newgrid.NextRow()
newgrid.NewButton("git pull", func() {
- rs.GitPull()
+ rs.pb.GitPull()
})
newgrid.NextRow()
diff --git a/new.go b/new.go
index 9fa15b9..a0e31a3 100644
--- a/new.go
+++ b/new.go
@@ -2,7 +2,6 @@ package repostatus
import (
"os"
- "strings"
"go.wit.com/lib/gadgets"
"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
func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
path := repo.GoPath
- goSrcDir := os.Getenv("FORGE_GOSRC")
- realpath := repo.FullPath
- isGoLang := true
-
if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
@@ -56,6 +51,9 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
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)
@@ -83,34 +81,33 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
// save ~/go/src & the whole path strings
rs.path.SetValue(path)
- rs.goSrcPath.SetValue(goSrcDir)
- rs.realPath.SetValue(realpath)
+ rs.goSrcPath.SetValue(os.Getenv("FORGE_GOSRC"))
+ rs.realPath.SetValue(rs.pb.GetFullPath())
// add all the tags
rs.makeTagBox(box2)
rs.readGitConfig()
- rs.readOnly.SetValue("true")
- // ignore everything else for now
- // todo: move this logic to cfgfile.go
- if strings.HasPrefix(path, "go.wit.com") {
- rs.readOnly.SetValue("false")
- }
- if strings.HasPrefix(path, "git.wit.org") {
+ 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())
- // tries 'master', 'main', etc.
- rs.guessMainWorkingName()
- // tries 'devel', etc
- rs.guessDevelWorkingName()
- // sets this to os.Username
- rs.setUserWorkingName()
+ rs.userWorkingName.SetText(rs.pb.GetUserBranchName())
+ rs.userBranchVersion.SetLabel(rs.pb.GetUserBranchName())
- if isGoLang {
+ if rs.pb.GoPath == "" {
+ // not golang repo
+ } else {
rs.isGoLang.SetText("true")
- rs.goPath.SetText(path)
+ rs.goPath.SetText(rs.pb.GoPath)
}
windowMap[path] = rs
return rs, nil
diff --git a/structs.go b/structs.go
index e30119e..7436ea3 100644
--- a/structs.go
+++ b/structs.go
@@ -3,6 +3,7 @@ package repostatus
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
+ "go.wit.com/lib/protobuf/gitpb"
)
type RepoStatus struct {
@@ -12,6 +13,8 @@ type RepoStatus struct {
tags map[string]string
InitOk bool // it takes a second or so to init these
+ pb *gitpb.Repo // the protobuf
+
// used to temporarily tell the automation tools to
// try to ignore this repo's changes and state
// specifically when doing formal releases, sometimes
@@ -72,7 +75,7 @@ type RepoStatus struct {
speedActual *gadgets.OneLiner
gitConfig *GitConfig
- goConfig GoConfig
+ // goConfig GoConfig
switchBranchB *gui.Node
targetBranch *gui.Node
diff --git a/tagWindow.go b/tagWindow.go
index 59caef5..fbd67dc 100644
--- a/tagWindow.go
+++ b/tagWindow.go
@@ -4,13 +4,11 @@ import (
"errors"
"path/filepath"
"regexp"
- "slices"
"strings"
"sync"
"time"
"go.wit.com/gui"
- "go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -88,49 +86,24 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
grid.NewLabel("ref")
grid.NewLabel("date")
grid.NewLabel("release subject")
- // works like a typerwriter
- grid.NextRow()
+ grid.NextRow() // works like a typerwriter newline
- // git tag --list --sort=taggerdate
- // git for-each-ref --sort=taggerdate --format '%(tag) %(*objectname) %(taggerdate)'
- // git rev-parse HEAD
- // if last tag == HEAD, then remove it
+ loop := rs.pb.Tags.SortByAge()
+ for loop.Scan() {
+ tag := loop.Next()
- 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.tag = grid.NewLabel(parts[3])
- rTag.ref = grid.NewEntrybox(parts[0])
+ rTag.tag = grid.NewLabel(tag.GetRefname())
+ rTag.ref = grid.NewEntrybox(tag.GetHash())
- _, stamp, dur := getGitDateStamp(parts[1])
- rTag.date = grid.NewLabel(stamp)
+ ctime := tag.GetAuthordate().AsTime()
+ dur := getDurationStamp(ctime)
+ rTag.date = grid.NewLabel(ctime.Format("YYYY/MM/DD"))
rTag.duration = grid.NewLabel(dur)
- rTag.subject = grid.NewLabel(parts[4])
+ rTag.subject = grid.NewLabel(tag.GetSubject())
rTag.deleteB = grid.NewButton("delete", func() {
- tagversion := parts[0]
+ tagversion := tag.GetRefname()
log.Info("remove tag", tagversion)
var all [][]string
all = append(all, []string{"git", "tag", "--delete", tagversion})
@@ -147,8 +120,6 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
// works like a typerwriter
grid.NextRow()
}
- // reverse the git order
- // slices.Reverse(rtags.tags)
return nil
}
diff --git a/unix.go b/unix.go
index 601015d..f91fd02 100644
--- a/unix.go
+++ b/unix.go
@@ -2,12 +2,10 @@ package repostatus
import (
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
"regexp"
- "strconv"
"strings"
"time"
@@ -179,6 +177,7 @@ func Exists(file string) bool {
return true
}
+/*
func readFileToString(filename string) (string, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
@@ -217,6 +216,7 @@ func getRawDateStamp(raw string) (time.Time, string, string) {
gitTagDate := time.Unix(i, 0)
return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
}
+*/
func getDurationStamp(t time.Time) string {
@@ -376,6 +376,7 @@ func (rs *RepoStatus) DoAll(all [][]string) bool {
return true
}
+/*
func ScanGitDirectories(srcDir string) []string {
var all []string
err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
@@ -398,3 +399,4 @@ func ScanGitDirectories(srcDir string) []string {
return all
}
+*/