Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Fix Repository#log pagination and order by date
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
  • Loading branch information
dzaporozhets committed Sep 26, 2014
1 parent dd1209c commit 8a5eee6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/gitlab_git/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def log(options)
options[:offset] ||= 0
actual_ref = options[:ref] || root_ref
sha = sha_from_ref(actual_ref)

build_log(sha, options)
rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError
# Return an empty array if the ref wasn't found
Expand Down Expand Up @@ -734,18 +733,22 @@ def build_log(sha, options)
commits = []
skipped = 0
current_path = options[:path]
current_path = nil if current_path == ''

limit = options[:limit].to_i
offset = options[:offset].to_i

walker.sorting(Rugged::SORT_DATE)
walker.each do |c|
break if options[:limit].to_i > 0 &&
commits.length >= options[:limit].to_i
break if limit > 0 && commits.length >= limit

if !current_path ||
commit_touches_path?(c, current_path, options[:follow])

# This is a commit we care about, unless we haven't skipped enough
# yet
skipped += 1
commits.push(c) if skipped > options[:offset]
commits.push(c) if skipped > offset
end
end

Expand Down

0 comments on commit 8a5eee6

Please sign in to comment.