From c09bbdf1f1331a38a5819b4e8b8b49dcc7ce722e Mon Sep 17 00:00:00 2001 From: Michael Siebert Date: Thu, 29 Jan 2015 15:38:32 +0100 Subject: [PATCH] Avoid Gitlab pagination when a commit has more than 20 comments This leads to duplicate comments. The ideal way would be to paginate through all comments (with link headers), but the Gitlab gem doesn't allow this currently. --- CHANGELOG.md | 3 +++ lib/pronto/gitlab.rb | 2 +- spec/pronto/gitlab_spec.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65434567..fee303e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Changes + +* [#58](https://github.com/mmozuras/pronto/pull/58): GitlabFormatter uses a high +per_page+ value to avoid pagination (and thus duplicate comments) ## 0.4.0 diff --git a/lib/pronto/gitlab.rb b/lib/pronto/gitlab.rb index 9584fa5a..ab237030 100644 --- a/lib/pronto/gitlab.rb +++ b/lib/pronto/gitlab.rb @@ -7,7 +7,7 @@ def initialize(repo) def commit_comments(sha) @comment_cache["#{sha}"] ||= begin - client.commit_comments(slug, sha).map do |comment| + client.commit_comments(slug, sha, per_page: 500).map do |comment| Comment.new(sha, comment.note, comment.path, comment.line) end end diff --git a/spec/pronto/gitlab_spec.rb b/spec/pronto/gitlab_spec.rb index d013f55c..301b6574 100644 --- a/spec/pronto/gitlab_spec.rb +++ b/spec/pronto/gitlab_spec.rb @@ -17,7 +17,7 @@ module Pronto ::Gitlab::Client.any_instance .should_receive(:commit_comments) - .with('mmozuras%2Fpronto', sha) + .with('mmozuras%2Fpronto', sha, per_page: 500) .once .and_return([])