From 88ca40bcfa11f464828cace14a07a9b59a00d571 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 16 Feb 2024 01:22:37 -0600 Subject: [PATCH] tag date format things --- common.go | 6 +++--- git.go | 8 ++++---- tagWindow.go | 19 ++++++++++--------- unix.go | 14 +++++++++++++- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/common.go b/common.go index 1b0f7a6..d725fbb 100644 --- a/common.go +++ b/common.go @@ -19,7 +19,7 @@ func (rs *RepoStatus) Changed() bool { // deprecate this. returns the gopath right now func (rs *RepoStatus) String() string { - log.Warn("RepoStatus.String() is to be deprecated") + // log.Warn("RepoStatus.String() is to be deprecated") return rs.path.String() } @@ -101,10 +101,10 @@ func (rs *RepoStatus) RepoType() string { err, output := rs.RunCmd([]string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}) if err == nil { output = strings.Trim(output, "'") - log.Info("go package is:", output) + // log.Info("go package is:", output) return output } - log.Info("package is: unknown", err) + // log.Info("package is: unknown", err) return "" } diff --git a/git.go b/git.go index 4875812..3a3fcdd 100644 --- a/git.go +++ b/git.go @@ -207,14 +207,14 @@ func (rs *RepoStatus) SetMainWorkingName(s string) { } _, ok := rs.gitConfig.branches[s] if ok { - log.Info("git branch", s, "seems to exist") + // log.Info("git branch", s, "seems to exist") rs.mainWorkingName.SetValue(s) return } s = "guimaster" _, ok = rs.gitConfig.branches[s] if ok { - log.Info("git branch", s, "seems to exist") + // log.Info("git branch", s, "seems to exist") rs.mainWorkingName.SetValue(s) return } @@ -222,7 +222,7 @@ func (rs *RepoStatus) SetMainWorkingName(s string) { s = "master" _, ok = rs.gitConfig.branches[s] if ok { - log.Info("git branch", s, "seems to exist") + // log.Info("git branch", s, "seems to exist") rs.mainWorkingName.SetValue(s) return } @@ -230,7 +230,7 @@ func (rs *RepoStatus) SetMainWorkingName(s string) { s = "main" _, ok = rs.gitConfig.branches[s] if ok { - log.Info("git branch", s, "seems to exist") + // log.Info("git branch", s, "seems to exist") rs.mainWorkingName.SetValue(s) return } diff --git a/tagWindow.go b/tagWindow.go index c476f8d..80f14cf 100644 --- a/tagWindow.go +++ b/tagWindow.go @@ -90,10 +90,10 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) { // git rev-parse HEAD // if last tag == HEAD, then remove it - tags := []string{"%(tag)", "%(*objectname)", "%(taggerdate:raw)", "%(subject)", "%(*authorname)", "%(*authoremail)"} + 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, " ")) + // log.Info("RUNNING:", strings.Join(cmd, " ")) err, output := rs.RunCmd(cmd) if err != nil { output = "git error_,,,_a_,,,_b_,,,c" @@ -106,21 +106,22 @@ func (rs *RepoStatus) makeTagBox(box *gui.Node) { for i, line := range lines { var parts []string - parts = make([]string, 6) + parts = make([]string, 0) parts = strings.Split(line, "_,,,_") - log.Info("found tag:", i, parts) - if parts[0] == "" { + if len(parts) != 5 { + log.Info("tag error:", i, parts) continue } + // log.Info("found tag:", i, parts) rTag := new(repoTag) - rTag.tag = grid.NewLabel(parts[0]) - rTag.ref = grid.NewEntrybox(parts[1]) + rTag.tag = grid.NewLabel(parts[3]) + rTag.ref = grid.NewEntrybox(parts[0]) - _, stamp, dur := getDateStamp(parts[2]) // + _, stamp, dur := getGitDateStamp(parts[1]) rTag.date = grid.NewLabel(stamp) grid.NewLabel(dur) - rTag.subject = grid.NewLabel(parts[3]) + rTag.subject = grid.NewLabel(parts[4]) rTag.deleteB = grid.NewButton("delete", func() { tagversion := parts[0] log.Info("remove tag", tagversion) diff --git a/unix.go b/unix.go index 7e295e8..b1fcff7 100644 --- a/unix.go +++ b/unix.go @@ -274,7 +274,19 @@ func readFileToString(filename string) (string, error) { return strings.TrimSpace(string(data)), nil } -func getDateStamp(raw string) (time.Time, string, string) { +// converts a git for-each-ref date. "Wed Feb 7 10:13:38 2024 -0600" +func getGitDateStamp(gitdefault string) (time.Time, string, string) { + // now := time.Now().Format("Wed Feb 7 10:13:38 2024 -0600") + const gitLayout = "Mon Jan 2 15:04:05 2006 -0700" + tagTime, err := time.Parse(gitLayout, gitdefault) + if err != nil { + log.Warn("GOT THIS IN PARSE AAA."+gitdefault+".AAA") + log.Warn(err) + return time.Now(), "Feb 1 12:34:56 1978 -0600", "" + } + return tagTime, gitdefault, getDurationStamp(tagTime) +} +func getRawDateStamp(raw string) (time.Time, string, string) { parts := strings.Split(raw, " ") if len(parts) == 0 { // raw was blank here