Class: Gitlab::Git::CommitStats

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_git/commit_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#additionsObject (readonly)

Returns the value of attribute additions.



6
7
8
# File 'lib/gitlab_git/commit_stats.rb', line 6

def additions
  @additions
end

#deletionsObject (readonly)

Returns the value of attribute deletions.



6
7
8
# File 'lib/gitlab_git/commit_stats.rb', line 6

def deletions
  @deletions
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/gitlab_git/commit_stats.rb', line 6

def id
  @id
end

#totalObject (readonly)

Returns the value of attribute total.



6
7
8
# File 'lib/gitlab_git/commit_stats.rb', line 6

def total
  @total
end