Class: Gitlab::Git::Compare
- Inherits:
-
Object
- Object
- Gitlab::Git::Compare
- Defined in:
- lib/gitlab_git/compare.rb
Instance Attribute Summary collapse
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#commits ⇒ Object
Returns the value of attribute commits.
-
#diffs ⇒ Object
Returns the value of attribute diffs.
-
#same ⇒ Object
Returns the value of attribute same.
Instance Method Summary collapse
-
#initialize(repository, from, to) ⇒ Compare
constructor
A new instance of Compare.
Constructor Details
#initialize(repository, from, to) ⇒ Compare
Returns a new instance of Compare.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab_git/compare.rb', line 6 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 = first @commits = repository.commits_between(last.id, first.id) @diffs = if @commits.size > 100 [] else repository.repo.diff(last.id, first.id) rescue [] end end |
Instance Attribute Details
#commit ⇒ Object
Returns the value of attribute commit.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def commit @commit end |
#commits ⇒ Object
Returns the value of attribute commits.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def commits @commits end |
#diffs ⇒ Object
Returns the value of attribute diffs.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def diffs @diffs end |
#same ⇒ Object
Returns the value of attribute same.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def same @same end |