Class: Gitlab::Git::CommitStats
- Inherits:
-
Object
- Object
- Gitlab::Git::CommitStats
- Defined in:
- lib/gitlab_git/commit_stats.rb
Instance Attribute Summary collapse
-
#additions ⇒ Object
readonly
Returns the value of attribute additions.
-
#deletions ⇒ Object
readonly
Returns the value of attribute deletions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(commit) ⇒ CommitStats
constructor
Instantiate a CommitStats object.
Constructor Details
#initialize(commit) ⇒ CommitStats
Instantiate a CommitStats object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitlab_git/commit_stats.rb', line 9 def initialize(commit) @id = commit.id @additions = 0 @deletions = 0 @total = 0 diff = commit.diff_from_parent diff.each_patch do |p| # TODO: Use the new Rugged convenience methods when they're released @additions += p.stat[0] @deletions += p.stat[1] @total += p.changes end end |
Instance Attribute Details
#additions ⇒ Object (readonly)
Returns the value of attribute additions.
6 7 8 |
# File 'lib/gitlab_git/commit_stats.rb', line 6 def additions @additions end |
#deletions ⇒ Object (readonly)
Returns the value of attribute deletions.
6 7 8 |
# File 'lib/gitlab_git/commit_stats.rb', line 6 def deletions @deletions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/gitlab_git/commit_stats.rb', line 6 def id @id end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/gitlab_git/commit_stats.rb', line 6 def total @total end |