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(paths = nil) ⇒ Object
Returns the value of attribute diffs.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#same ⇒ Object
Returns the value of attribute same.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #commits_over_limit? ⇒ Boolean
-
#empty_diff? ⇒ Boolean
Check if diff is empty because it is actually empty and not because its impossible to get it.
-
#initialize(repository, from, to, limit = 100) ⇒ Compare
constructor
A new instance of Compare.
Constructor Details
#initialize(repository, from, to, limit = 100) ⇒ 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 |
# File 'lib/gitlab_git/compare.rb', line 6 def initialize(repository, from, to, limit = 100) @commits, @diffs = [], [] @commit = nil @same = false @limit = limit @repository = repository @timeout = false return unless from && to @base = Gitlab::Git::Commit.find(repository, from.try(:strip)) @head = Gitlab::Git::Commit.find(repository, to.try(:strip)) return unless @base && @head if @base.id == @head.id @same = true return end @commit = @head @commits = Gitlab::Git::Commit.between(repository, @base.id, @head.id) 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(paths = nil) ⇒ Object
Returns the value of attribute diffs.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def diffs @diffs end |
#limit ⇒ Object
Returns the value of attribute limit.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def limit @limit end |
#same ⇒ Object
Returns the value of attribute same.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def same @same end |
#timeout ⇒ Object
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/gitlab_git/compare.rb', line 4 def timeout @timeout end |
Instance Method Details
#commits_over_limit? ⇒ Boolean
55 56 57 |
# File 'lib/gitlab_git/compare.rb', line 55 def commits_over_limit? commits.size > limit end |
#empty_diff? ⇒ Boolean
Check if diff is empty because it is actually empty and not because its impossible to get it
51 52 53 |
# File 'lib/gitlab_git/compare.rb', line 51 def empty_diff? diffs.empty? && timeout == false && commits.size < limit end |