Skip to content

Commit

Permalink
Avoid Gitlab pagination when a commit has more than 20 comments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
siebertm committed Jan 29, 2015
1 parent 9a751e5 commit c09bbdf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/pronto/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/pronto/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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([])

Expand Down

0 comments on commit c09bbdf

Please sign in to comment.