Commit bb06e905 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

added Gitlab::Git::Compare for git compare feature

parent 51c16755
module Gitlab
module Git
class Compare
attr_accessor :commits, :commit, :diffs, :same
def initialize(repository, from, to)
@commits, @diffs = [], []
@commit = nil
@same = false
return unless from && to
first = repository.commit(to.try(:strip))
last = repository.commit(from.try(:strip))
return unless first && last
if first.id == last.id
@same = true
return
end
@commit = Commit.new(first)
@commits = repository.commits_between(last.id, first.id)
@commits = @commits.map { |c| Commit.new(c) }
@diffs = if @commits.size > 100
[]
else
repository.repo.diff(last.id, first.id) rescue []
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment