diff options
| author | Jeff Carr <[email protected]> | 2024-12-06 01:50:28 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-06 01:50:28 -0600 |
| commit | 945ae6329b7e4e46e409027984253e358ee87260 (patch) | |
| tree | 6b512584d838865c3e187296b545da18797b2f24 /gitTag.byAge.go | |
| parent | 205e6f022befe1cee748765c71e688b532e03fcb (diff) | |
early 'git pull' using rillv0.0.26
Diffstat (limited to 'gitTag.byAge.go')
| -rw-r--r-- | gitTag.byAge.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gitTag.byAge.go b/gitTag.byAge.go new file mode 100644 index 0000000..9d62acf --- /dev/null +++ b/gitTag.byAge.go @@ -0,0 +1,31 @@ +package gitpb + +// runs git, parses output +// types faster than you can + +import ( + "sort" + "time" +) + +func (all *GitTags) SortByAge() *GitTagIterator { + packs := all.selectAllGitTag() + + sort.Sort(GitTagAge(packs)) + + iterator := NewGitTagIterator(packs) + return iterator +} + +type GitTagAge []*GitTag + +func (a GitTagAge) 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()) { + return true + } + return false +} +func (a GitTagAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
