From 442a6e880058138b6ae6843d9b70d62cbc5aadb0 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Fri, 16 Feb 2018 16:39:23 +0000 Subject: API method /projects/:id/repository/commits now works over every commit --- lib/api/commits.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/api/commits.rb') diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 3d6e78d2d80..c4a180d3b0e 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -18,25 +18,28 @@ module API optional :since, type: DateTime, desc: 'Only commits after or on this date will be returned' optional :until, type: DateTime, desc: 'Only commits before or on this date will be returned' optional :path, type: String, desc: 'The file path' + optional :all, type: Boolean, desc: 'Every commit will be returned' use :pagination end get ':id/repository/commits' do path = params[:path] before = params[:until] after = params[:since] - ref = params[:ref_name] || user_project.try(:default_branch) || 'master' + ref = params[:ref_name] || user_project.try(:default_branch) || 'master' unless params[:all] offset = (params[:page] - 1) * params[:per_page] + all = params[:all] commits = user_project.repository.commits(ref, path: path, limit: params[:per_page], offset: offset, before: before, - after: after) + after: after, + all: all) commit_count = if path || before || after - user_project.repository.count_commits(ref: ref, path: path, before: before, after: after) + user_project.repository.count_commits(ref: ref, path: path, before: before, after: after, all: all) else # Cacheable commit count. user_project.repository.commit_count_for_ref(ref) -- cgit v1.2.1 From cd9daf644e2b3844b9382768a3add335f942b76c Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 19 Feb 2018 14:42:00 +0000 Subject: Add specs --- lib/api/commits.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/commits.rb') diff --git a/lib/api/commits.rb b/lib/api/commits.rb index c4a180d3b0e..982f45425a3 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -38,7 +38,7 @@ module API all: all) commit_count = - if path || before || after + if all || path || before || after user_project.repository.count_commits(ref: ref, path: path, before: before, after: after, all: all) else # Cacheable commit count. -- cgit v1.2.1