diff options
author | George Andrinopoulos <geoandri@gmail.com> | 2017-02-05 11:30:36 +0200 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-07 22:56:31 -0300 |
commit | c46f933bb7cb6eccdf648112a57872dc24ebf3ad (patch) | |
tree | 6ee07d0695655e1bd91ef083c2c7a8cf3b2caad3 /lib/gitlab/git | |
parent | 473cab818aff034d072f0f6c8537a584bc5aa41c (diff) | |
download | gitlab-ce-c46f933bb7cb6eccdf648112a57872dc24ebf3ad.tar.gz |
Fix pagination headers for repository commits api endpoint
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/repository.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 6540730ca7a..0f092d4c4ab 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -292,7 +292,6 @@ module Gitlab } options = default_options.merge(options) - options[:limit] ||= 0 options[:offset] ||= 0 actual_ref = options[:ref] || root_ref begin @@ -354,6 +353,16 @@ module Gitlab lines.map! { |c| Rugged::Commit.new(rugged, c.strip) } end + def count_commits(options) + cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path} rev-list) + cmd += %W(--after=#{options[:after].iso8601}) if options[:after] + cmd += %W(--before=#{options[:before].iso8601}) if options[:before] + cmd += %W(--count #{options[:ref]}) + cmd += %W(-- #{options[:path]}) if options[:path].present? + raw_output = IO.popen(cmd) {|io| io.read } + raw_output.to_i + end + def sha_from_ref(ref) rev_parse_target(ref).oid end |