lib/gitlab_git/compare.rb in gitlab_git-8.2.0 vs lib/gitlab_git/compare.rb in gitlab_git-9.0.0
- old
+ new
@@ -1,15 +1,14 @@
module Gitlab
module Git
class Compare
- attr_reader :commits, :diffs, :same, :timeout, :head, :base
+ attr_reader :commits, :same, :head, :base
def initialize(repository, base, head)
- @commits, @diffs = [], []
+ @commits = []
@same = false
@repository = repository
- @timeout = false
return unless base && head
@base = Gitlab::Git::Commit.find(repository, base.try(:strip))
@head = Gitlab::Git::Commit.find(repository, head.try(:strip))
@@ -22,33 +21,16 @@
end
@commits = Gitlab::Git::Commit.between(repository, @base.id, @head.id)
end
- def diffs(paths = nil, options = {})
+ def diffs(options = {})
unless @head && @base
- return []
+ return Gitlab::Git::DiffCollection.new([])
end
- # Try to collect diff only if diffs is empty
- # Otherwise return cached version
- if @diffs.empty? && @timeout == false
- begin
- @diffs = Gitlab::Git::Diff.between(@repository, @head.id, @base.id,
- options, *paths)
- rescue Gitlab::Git::Diff::TimeoutError => ex
- @diffs = []
- @timeout = true
- end
- end
-
- @diffs
- end
-
- # Check if diff is empty because it is actually empty
- # and not because its impossible to get it
- def empty_diff?
- diffs.empty? && timeout == false
+ paths = options.delete(:paths) || []
+ Gitlab::Git::Diff.between(@repository, @head.id, @base.id, options, *paths)
end
end
end
end