web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

sort tags and deduplicate

This sorts the tags reverse-chronologically.

If any tags have the same name (shouldn't happen but it does in some of my
repos), we use whichever one is "newer".

Signed-off-by: Derek Stevens <nilix@nilfm.cc>

authored by

Derek Stevens and committed by
Anirudh Oppiliappan
3060c752 e782f36f

+28
+28
git/git.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "sort" 5 6 6 7 "github.com/go-git/go-git/v5" 7 8 "github.com/go-git/go-git/v5/plumbing" ··· 11 12 type GitRepo struct { 12 13 r *git.Repository 13 14 h plumbing.Hash 15 + } 16 + 17 + type TagList []*object.Tag 18 + 19 + func (self TagList) Len() int { 20 + return len(self) 21 + } 22 + 23 + func (self TagList) Swap(i, j int) { 24 + self[i], self[j] = self[j], self[i] 25 + } 26 + 27 + // sorting tags in reverse chronological order 28 + func (self TagList) Less(i, j int) bool { 29 + return self[i].Tagger.When.After(self[j].Tagger.When) 14 30 } 15 31 16 32 func Open(path string, ref string) (*GitRepo, error) { ··· 94 110 tags := []*object.Tag{} 95 111 96 112 _ = ti.ForEach(func(t *object.Tag) error { 113 + for i, existing := range tags { 114 + if existing.Name == t.Name { 115 + if t.Tagger.When.After(existing.Tagger.When) { 116 + tags[i] = t 117 + } 118 + return nil 119 + } 120 + } 97 121 tags = append(tags, t) 98 122 return nil 99 123 }) 124 + 125 + var tagList TagList 126 + tagList = tags 127 + sort.Sort(tagList) 100 128 101 129 return tags, nil 102 130 }