diff options
author | Jordan Ryan Reuter <jordan.reuter@scimedsolutions.com> | 2017-01-20 10:04:16 -0500 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-07 22:56:30 -0300 |
commit | 473cab818aff034d072f0f6c8537a584bc5aa41c (patch) | |
tree | 1425966bf2f786870bbb2a613c31123aa1743c25 /lib/api/commits.rb | |
parent | 2995f48ef3158252446c5e03c138feb6c1889941 (diff) | |
download | gitlab-ce-473cab818aff034d072f0f6c8537a584bc5aa41c.tar.gz |
Manually set total_count when paginating commits
`Kaminari.paginate_array` takes some options, most relevant of which is
a `total_count` parameter. Using the `commit_count` for `total_count`
lets us correctly treat the return of `Repository#commits` as a subset
of all the commits we may wish to list.
Addition of a new `Repository#commit_count_for_ref` method was
necessarry to allow the user to start from an arbitrary ref.
Ref #1381
Diffstat (limited to 'lib/api/commits.rb')
-rw-r--r-- | lib/api/commits.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index b0aa10f8bf2..6205bff3bc0 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -33,7 +33,10 @@ module API after: params[:since], before: params[:until]) - present commits, with: Entities::RepoCommit + commit_count = user_project.repository.commit_count_for_ref(ref) + paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count) + + present paginate(paginated_commits), with: Entities::RepoCommit end desc 'Commit multiple file changes as one commit' do |