From 612264a00f352a12620bab3c72cd0b11b304f5e2 Mon Sep 17 00:00:00 2001 From: Amine Hilaly Date: Fri, 12 Jul 2019 17:48:57 +0200 Subject: bridge/gitlab: fix iterator out of index bug --- bridge/gitlab/iterator.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bridge/gitlab') diff --git a/bridge/gitlab/iterator.go b/bridge/gitlab/iterator.go index 724d1c73..a0f2907b 100644 --- a/bridge/gitlab/iterator.go +++ b/bridge/gitlab/iterator.go @@ -106,7 +106,7 @@ func (i *iterator) NextIssue() bool { } // move cursor index - if i.issue.index < min(i.capacity, len(i.issue.cache)) { + if i.issue.index < min(i.capacity, len(i.issue.cache))-1 { i.issue.index++ return true } @@ -126,6 +126,7 @@ func (i *iterator) NextIssue() bool { i.issue.page++ i.issue.index = 0 i.comment.index = 0 + i.issue.cache = issues return true } @@ -149,6 +150,10 @@ func (i *iterator) getComments() ([]*gitlab.Note, error) { return notes, err } +func (i *iterator) getNextComments() bool { + return false +} + func (i *iterator) NextComment() bool { if i.err != nil { return false @@ -168,6 +173,7 @@ func (i *iterator) NextComment() bool { return false } + i.comment.cache = comments i.comment.page++ i.comment.index = 0 @@ -175,7 +181,7 @@ func (i *iterator) NextComment() bool { } // move cursor index - if i.comment.index < min(i.capacity, len(i.comment.cache)) { + if i.comment.index < min(i.capacity, len(i.comment.cache))-1 { i.comment.index++ return true } @@ -193,6 +199,7 @@ func (i *iterator) NextComment() bool { return false } + i.comment.cache = comments i.comment.page++ i.comment.index = 0 -- cgit