summaryrefslogtreecommitdiff
path: root/gitTag.byAge.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-11-05 15:29:40 -0600
committerJeff Carr <[email protected]>2025-11-05 15:29:40 -0600
commit12b751cc7fbaa09f205c6207c355300f15885441 (patch)
treed1ba97cbdc5f6d9c86d94206dc89eb1c878f7c97 /gitTag.byAge.go
parentb7efa450a8a220625174f21ae15f9b7ea1cd3a3b (diff)
compiles against stat.protov0.0.182
Diffstat (limited to 'gitTag.byAge.go')
-rw-r--r--gitTag.byAge.go74
1 files changed, 37 insertions, 37 deletions
diff --git a/gitTag.byAge.go b/gitTag.byAge.go
index aac234d..33e4f37 100644
--- a/gitTag.byAge.go
+++ b/gitTag.byAge.go
@@ -12,8 +12,8 @@ import (
// todo: probably switch to using slices. new things added in 1.23
// https://pkg.go.dev/slices
-func (all *GitTags) newSort() *GitTagScanner {
- slices.SortFunc(all.GitTags, func(a, b *GitTag) int {
+func (all *Stats) newSort() *StatScanner {
+ slices.SortFunc(all.Stats, func(a, b *Stat) int {
if n := strings.Compare(a.Name, b.Name); n != 0 {
return n
}
@@ -25,62 +25,62 @@ func (all *GitTags) newSort() *GitTagScanner {
// all this code below is junk and seamingly wrong
-func (all *GitTags) GetAge(name string) time.Time {
- packs := all.selectAllGitTags()
+func (all *Stats) GetAge(name string) time.Time {
+ packs := all.selectAllStats()
var newest time.Time
for _, tag := range packs {
- // log.Info("\t\ttag", i, tag.Refname, tag.Authordate.AsTime())
- _, rname := filepath.Split(tag.Refname)
+ // log.Info("\t\ttag", i, tag.Name, tag.AuthorTime.AsTime())
+ _, rname := filepath.Split(tag.Name)
if name == rname {
- // log.Info("\t\tfound tag", i, rbase, rname, tag.Authordate.AsTime())
- newest = tag.Authordate.AsTime()
+ // log.Info("\t\tfound tag", i, rbase, rname, tag.AuthorTime.AsTime())
+ newest = tag.AuthorTime.AsTime()
return newest
}
- newest = tag.Authordate.AsTime()
+ newest = tag.AuthorTime.AsTime()
}
return newest
}
-func (all *GitTags) SortByAge() *GitTagScanner {
- packs := all.selectAllGitTags()
+func (all *Stats) SortByAge() *StatScanner {
+ packs := all.selectAllStats()
- sort.Sort(GitTagAge(packs))
+ sort.Sort(StatAge(packs))
- iterator := newGitTagScanner(packs)
+ iterator := newStatScanner(packs)
return iterator
}
-type GitTagAge []*GitTag
+type StatAge []*Stat
-func (a GitTagAge) Len() int { return len(a) }
+func (a StatAge) Len() int { return len(a) }
// sorts in ? order
-func (a GitTagAge) Less(i, j int) bool {
- if time.Since(a[i].Authordate.AsTime()) < time.Since(a[j].Authordate.AsTime()) {
+func (a StatAge) Less(i, j int) bool {
+ if time.Since(a[i].AuthorTime.AsTime()) < time.Since(a[j].AuthorTime.AsTime()) {
return true
}
return false
}
-func (a GitTagAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a StatAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// biased code that gives out newer tag dates
// even if the code hasn't been patched
func (repo *Repo) NewestAge() time.Duration {
- alltags := repo.Tags.selectAllGitTags()
+ alltags := repo.Tags.selectAllStats()
var newest time.Time
for _, tag := range alltags {
// check the actual age of the patch
- if newest.Before(tag.Authordate.AsTime()) {
- newest = tag.Authordate.AsTime()
+ if newest.Before(tag.AuthorTime.AsTime()) {
+ newest = tag.AuthorTime.AsTime()
}
// check the age of the commit
- if newest.Before(tag.Creatordate.AsTime()) {
- newest = tag.Creatordate.AsTime()
+ if newest.Before(tag.CommitTime.AsTime()) {
+ newest = tag.CommitTime.AsTime()
}
}
@@ -88,18 +88,18 @@ func (repo *Repo) NewestAge() time.Duration {
}
func (repo *Repo) NewestTime() time.Time {
- alltags := repo.Tags.selectAllGitTags()
+ alltags := repo.Tags.selectAllStats()
var newest time.Time
for _, tag := range alltags {
// check the actual age of the patch
- if newest.Before(tag.Authordate.AsTime()) {
- newest = tag.Authordate.AsTime()
+ if newest.Before(tag.AuthorTime.AsTime()) {
+ newest = tag.AuthorTime.AsTime()
}
// check the age of the commit
- if newest.Before(tag.Creatordate.AsTime()) {
- newest = tag.Creatordate.AsTime()
+ if newest.Before(tag.CommitTime.AsTime()) {
+ newest = tag.CommitTime.AsTime()
}
}
@@ -107,15 +107,15 @@ func (repo *Repo) NewestTime() time.Time {
}
func (repo *Repo) NewestAgeVerbose() time.Duration {
- alltags := repo.Tags.selectAllGitTags()
+ alltags := repo.Tags.selectAllStats()
var newest time.Time
var cur time.Time
for i, tag := range alltags {
- cur = tag.Authordate.AsTime()
- rbase, rname := filepath.Split(tag.Refname)
- log.Info("\t\tfound tag", i, rbase, rname, tag.Authordate.AsTime(), tag.Creatordate.AsTime())
+ cur = tag.AuthorTime.AsTime()
+ rbase, rname := filepath.Split(tag.Name)
+ log.Info("\t\tfound tag", i, rbase, rname, tag.AuthorTime.AsTime(), tag.CommitTime.AsTime())
if newest.Before(cur) {
newest = cur
}
@@ -126,17 +126,17 @@ func (repo *Repo) NewestAgeVerbose() time.Duration {
// not really accurate. temprorary until git Config() parsing is better
func (repo *Repo) BranchAge(branch string) time.Duration {
- alltags := repo.Tags.selectAllGitTags()
+ alltags := repo.Tags.selectAllStats()
var newest time.Time
var cur time.Time
var auth time.Time
for _, tag := range alltags {
- cur = tag.Creatordate.AsTime()
- auth = tag.Authordate.AsTime()
- if branch == filepath.Base(tag.Refname) {
- // log.Info("\t\tfound tag", i, branch, tag.Authordate.AsTime(), tag.Creatordate.AsTime())
+ cur = tag.CommitTime.AsTime()
+ auth = tag.AuthorTime.AsTime()
+ if branch == filepath.Base(tag.Name) {
+ // log.Info("\t\tfound tag", i, branch, tag.AuthorTime.AsTime(), tag.CommitTime.AsTime())
if cur.Before(auth) {
return time.Since(auth)
}