Class: Gitlab::Git::CommitStats

Inherits:
Object
  • Object
show all
Includes:
WrapsGitalyErrors
Defined in:
lib/gitlab/git/commit_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WrapsGitalyErrors

#wrapped_gitaly_errors

Constructor Details

#initialize(repo, commit) ⇒ CommitStats

Instantiate a CommitStats object

Gitaly migration: gitlab.com/gitlab-org/gitaly/issues/323


15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/git/commit_stats.rb', line 15

def initialize(repo, commit)
  @id = commit.id
  @additions = 0
  @deletions = 0
  @total = 0

  wrapped_gitaly_errors do
    gitaly_stats(repo, commit)
  end
end

Instance Attribute Details

#additionsObject (readonly)

Returns the value of attribute additions


10
11
12
# File 'lib/gitlab/git/commit_stats.rb', line 10

def additions
  @additions
end

#deletionsObject (readonly)

Returns the value of attribute deletions


10
11
12
# File 'lib/gitlab/git/commit_stats.rb', line 10

def deletions
  @deletions
end

#idObject (readonly)

Returns the value of attribute id


10
11
12
# File 'lib/gitlab/git/commit_stats.rb', line 10

def id
  @id
end

#totalObject (readonly)

Returns the value of attribute total


10
11
12
# File 'lib/gitlab/git/commit_stats.rb', line 10

def total
  @total
end

Instance Method Details

#gitaly_stats(repo, commit) ⇒ Object


26
27
28
29
30
31
# File 'lib/gitlab/git/commit_stats.rb', line 26

def gitaly_stats(repo, commit)
  stats = repo.gitaly_commit_client.commit_stats(@id)
  @additions = stats.additions
  @deletions = stats.deletions
  @total = @additions + @deletions
end