Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/commits.rb')
-rw-r--r--lib/api/commits.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 20877fb5c5f..3097bcc0ef1 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -62,19 +62,29 @@ module API
first_parent: first_parent,
order: order)
- commit_count =
- if all || path || before || after || first_parent
- user_project.repository.count_commits(ref: ref, path: path, before: before, after: after, all: all, first_parent: first_parent)
- else
- # Cacheable commit count.
- user_project.repository.commit_count_for_ref(ref)
- end
+ serializer = with_stats ? Entities::CommitWithStats : Entities::Commit
- paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count)
+ if Feature.enabled?(:api_commits_without_count, user_project)
+ # This tells kaminari that there is 1 more commit after the one we've
+ # loaded, meaning there will be a next page, if the currently loaded set
+ # of commits is equal to the requested page size.
+ commit_count = offset + commits.size + 1
+ paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count)
- serializer = with_stats ? Entities::CommitWithStats : Entities::Commit
+ present paginate(paginated_commits, exclude_total_headers: true), with: serializer
+ else
+ commit_count =
+ if all || path || before || after || first_parent
+ user_project.repository.count_commits(ref: ref, path: path, before: before, after: after, all: all, first_parent: first_parent)
+ else
+ # Cacheable commit count.
+ user_project.repository.commit_count_for_ref(ref)
+ end
- present paginate(paginated_commits), with: serializer
+ paginated_commits = Kaminari.paginate_array(commits, total_count: commit_count)
+
+ present paginate(paginated_commits), with: serializer
+ end
end
desc 'Commit multiple file changes as one commit' do