attempt SortByAge(). not sure if it works.
This commit is contained in:
parent
4b83d18db4
commit
345343647a
|
@ -6,7 +6,9 @@ package gitpb
|
|||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"go.wit.com/log"
|
||||
|
@ -213,3 +215,29 @@ func trimNonNumericFromStart(s string) string {
|
|||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
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] }
|
||||
|
||||
func (repo *Repo) SetTargetVersion(target string) {
|
||||
repo.TargetVersion = target
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ func (repo *Repo) isPrimativeGoMod() (bool, error) {
|
|||
|
||||
}
|
||||
}
|
||||
repo.GoPrimitive = true
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ message Repo { // `autogenpb:marshal`
|
|||
google.protobuf.Timestamp lastGoDep = 13; // last time go.sum was processed
|
||||
bool dirty = 14; // if git says things have been changed
|
||||
GoDeps published = 15; // the last published go.mod/go.sum
|
||||
string targetVersion = 16; // useful during the package release process
|
||||
}
|
||||
|
||||
message Repos { // `autogenpb:marshal`
|
||||
|
|
Loading…
Reference in New Issue