aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/gitlab/iterator.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/bridge/gitlab/iterator.go b/bridge/gitlab/iterator.go
index bab35d95..f2fb0c2b 100644
--- a/bridge/gitlab/iterator.go
+++ b/bridge/gitlab/iterator.go
@@ -191,6 +191,58 @@ func (i *iterator) NoteValue() *gitlab.Note {
return i.note.cache[i.note.index]
}
+func (i *iterator) getNextLabelEvents() bool {
+ labelEvents, _, err := i.gc.ResourceLabelEvents.ListIssueLabelEvents(
+ i.project,
+ i.IssueValue().IID,
+ &gitlab.ListLabelEventsOptions{
+ ListOptions: gitlab.ListOptions{
+ Page: i.labelEvent.page,
+ PerPage: i.capacity,
+ },
+ },
+ )
+
+ if err != nil {
+ i.err = err
+ return false
+ }
+
+ if len(labelEvents) == 0 {
+ i.labelEvent.page = 1
+ i.labelEvent.index = -1
+ i.labelEvent.cache = nil
+ return false
+ }
+
+ i.labelEvent.cache = labelEvents
+ i.labelEvent.page++
+ i.labelEvent.index = 0
+ return true
+}
+
+func (i *iterator) NextLabelEvent() bool {
+ if i.err != nil {
+ return false
+ }
+
+ if len(i.labelEvent.cache) == 0 {
+ return i.getNextLabelEvents()
+ }
+
+ // move cursor index
+ if i.labelEvent.index < min(i.capacity, len(i.labelEvent.cache))-1 {
+ i.labelEvent.index++
+ return true
+ }
+
+ return i.getNextLabelEvents()
+}
+
+func (i *iterator) LabelEventValue() *gitlab.LabelEvent {
+ return i.labelEvent.cache[i.labelEvent.index]
+}
+
func min(a, b int) int {
if a > b {
return b