diff options
Diffstat (limited to 'bridge/gitlab/iterator.go')
-rw-r--r-- | bridge/gitlab/iterator.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bridge/gitlab/iterator.go b/bridge/gitlab/iterator.go index 198af79b..d5425cee 100644 --- a/bridge/gitlab/iterator.go +++ b/bridge/gitlab/iterator.go @@ -2,6 +2,7 @@ package gitlab import ( "context" + "sort" "time" "github.com/xanzy/go-gitlab" @@ -25,6 +26,20 @@ type labelEventIterator struct { cache []*gitlab.LabelEvent } +func (l *labelEventIterator) Len() int { + return len(l.cache) +} + +func (l *labelEventIterator) Swap(i, j int) { + element := l.cache[i] + l.cache[i] = l.cache[j] + l.cache[j] = element +} + +func (l *labelEventIterator) Less(i, j int) bool { + return l.cache[i].ID < l.cache[j].ID +} + type iterator struct { // gitlab api v4 client gc *gitlab.Client @@ -240,6 +255,8 @@ func (i *iterator) getNextLabelEvents() bool { i.labelEvent.cache = labelEvents i.labelEvent.page++ i.labelEvent.index = 0 + + sort.Sort(i.labelEvent) return true } |