Skip to content

Commit

Permalink
Support pagination in compare
Browse files Browse the repository at this point in the history
As per [this announcement](https://github.blog/changelog/2021-03-22-compare-rest-api-now-supports-pagination/), the Compare REST API now supports pagination of commits.
  • Loading branch information
mrpinsky authored and Nate Pinsky committed Jul 21, 2021
1 parent be7c105 commit f8f1293
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/octokit/client/commits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,18 @@ def create_commit(repo, message, tree, parents=nil, options = {})

# Compare two commits
#
# When using auto_pagination, commits from all pages will be concatenated
# into the <tt>commits</tt> attribute of the first page's response.
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param start [String] The sha of the starting commit
# @param endd [String] The sha of the ending commit
# @return [Sawyer::Resource] A hash representing the comparison
# @see https://developer.github.com/v3/repos/commits/#compare-two-commits
def compare(repo, start, endd, options = {})
get "#{Repository.path repo}/compare/#{start}...#{endd}", options
paginate "#{Repository.path repo}/compare/#{start}...#{endd}", options do |data, last_response|
data.commits.concat last_response.data.commits
end
end

# Merge a branch or sha
Expand Down
Loading

0 comments on commit f8f1293

Please sign in to comment.