Class: Gitlab::Git::Compare
- Inherits:
-
Object
- Object
- Gitlab::Git::Compare
- Defined in:
- lib/gitlab_git/compare.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#diffs(paths = nil, options = {}) ⇒ Object
readonly
Returns the value of attribute diffs.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#same ⇒ Object
readonly
Returns the value of attribute same.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#empty_diff? ⇒ Boolean
Check if diff is empty because it is actually empty and not because its impossible to get it.
-
#initialize(repository, base, head) ⇒ Compare
constructor
A new instance of Compare.
Constructor Details
#initialize(repository, base, head) ⇒ 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 |
# File 'lib/gitlab_git/compare.rb', line 6 def initialize(repository, base, head) @commits, @diffs = [], [] @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)) return unless @base && @head if @base.id == @head.id @same = true return end @commits = Gitlab::Git::Commit.between(repository, @base.id, @head.id) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def base @base end |
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def commits @commits end |
#diffs(paths = nil, options = {}) ⇒ Object (readonly)
Returns the value of attribute diffs.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def diffs @diffs end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def head @head end |
#same ⇒ Object (readonly)
Returns the value of attribute same.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def same @same end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def timeout @timeout end |
Instance Method Details
#empty_diff? ⇒ Boolean
Check if diff is empty because it is actually empty and not because its impossible to get it
49 50 51 |
# File 'lib/gitlab_git/compare.rb', line 49 def empty_diff? diffs.empty? && timeout == false end |