diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-02-16 16:39:23 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-02-23 10:09:46 +0000 |
commit | 442a6e880058138b6ae6843d9b70d62cbc5aadb0 (patch) | |
tree | 095c8713738a8690056b27bb2ca226477a2dc27d /lib | |
parent | 981b5905a02ac89ca9f33ad7c91d8c1a576ed9af (diff) | |
download | gitlab-ce-442a6e880058138b6ae6843d9b70d62cbc5aadb0.tar.gz |
API method /projects/:id/repository/commits now works over every commit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/commits.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 33 |
2 files changed, 30 insertions, 12 deletions
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) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index e3cbf017e55..e51cdac4a04 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -489,13 +489,16 @@ module Gitlab # Used in gitaly-ruby def raw_log(options) - actual_ref = options[:ref] || root_ref - begin - sha = sha_from_ref(actual_ref) - rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError - # Return an empty array if the ref wasn't found - return [] - end + sha = + unless options[:all] + actual_ref = options[:ref] || root_ref + begin + sha_from_ref(actual_ref) + rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError + # Return an empty array if the ref wasn't found + return [] + end + end log_by_shell(sha, options) end @@ -1701,7 +1704,12 @@ module Gitlab cmd << '--no-merges' if options[:skip_merges] cmd << "--after=#{options[:after].iso8601}" if options[:after] cmd << "--before=#{options[:before].iso8601}" if options[:before] - cmd << sha + + if options[:all] + cmd += %w[--all --reverse] + elsif sha + cmd << sha + end # :path can be a string or an array of strings if options[:path].present? @@ -1918,8 +1926,15 @@ module Gitlab cmd << "--before=#{options[:before].iso8601}" if options[:before] cmd << "--max-count=#{options[:max_count]}" if options[:max_count] cmd << "--left-right" if options[:left_right] - cmd += %W[--count #{options[:ref]}] + + if options[:all] + cmd += %w[--count --all] + elsif options[:ref].present? + cmd += %W[--count #{options[:ref]}] + end + cmd += %W[-- #{options[:path]}] if options[:path].present? + cmd end |