lib/gitlab_git/repository.rb in gitlab_git-10.0.1 vs lib/gitlab_git/repository.rb in gitlab_git-10.0.2
- old
+ new
@@ -233,21 +233,24 @@
# repo.log(
# ref: 'master',
# path: 'app/models',
# limit: 10,
# offset: 5,
+ # after: Time.new(2016, 4, 21, 14, 32, 10)
# )
#
def log(options)
default_options = {
limit: 10,
offset: 0,
path: nil,
ref: root_ref,
follow: false,
skip_merges: false,
- disable_walk: false
+ disable_walk: false,
+ after: nil,
+ before: nil
}
options = default_options.merge(options)
options[:limit] ||= 0
options[:offset] ||= 0
@@ -257,19 +260,23 @@
rescue Rugged::OdbError, Rugged::InvalidError, Rugged::ReferenceError
# Return an empty array if the ref wasn't found
return []
end
- if can_walk?(options)
- log_by_walk(sha, options)
- else
+ if log_using_shell?(options)
log_by_shell(sha, options)
+ else
+ log_by_walk(sha, options)
end
end
- def can_walk?(options)
- options[:path].blank? && !options[:skip_merges] && !options[:disable_walk]
+ def log_using_shell?(options)
+ options[:path].present? ||
+ options[:disable_walk] ||
+ options[:skip_merges] ||
+ options[:after] ||
+ options[:before]
end
def log_by_walk(sha, options)
walk_options = {
show: sha,
@@ -285,9 +292,11 @@
cmd += %W(-n #{options[:limit].to_i})
cmd += %W(--format=%H)
cmd += %W(--skip=#{options[:offset].to_i})
cmd += %W(--follow) if options[:follow]
cmd += %W(--no-merges) if options[:skip_merges]
+ cmd += %W(--after=#{options[:after].iso8601}) if options[:after]
+ cmd += %W(--before=#{options[:before].iso8601}) if options[:before]
cmd += [sha]
cmd += %W(-- #{options[:path]}) if options[:path].present?
raw_output = IO.popen(cmd) {|io| io.read }