Class: Gitlab::Git::CommitStats
- Inherits:
-
Object
- Object
- Gitlab::Git::CommitStats
- Includes:
- WrapsGitalyErrors
- 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
- #fetch_stats(repo, commit) ⇒ Object
-
#initialize(repo, commit) ⇒ CommitStats
constructor
Instantiate a CommitStats object.
Methods included from WrapsGitalyErrors
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 |
# File 'lib/gitlab/git/commit_stats.rb', line 15 def initialize(repo, commit) @id = commit.id additions, deletions = fetch_stats(repo, commit) @additions = additions.to_i @deletions = deletions.to_i @total = @additions + @deletions end |
Instance Attribute Details
#additions ⇒ Object (readonly)
Returns the value of attribute additions.
10 11 12 |
# File 'lib/gitlab/git/commit_stats.rb', line 10 def additions @additions end |
#deletions ⇒ Object (readonly)
Returns the value of attribute deletions.
10 11 12 |
# File 'lib/gitlab/git/commit_stats.rb', line 10 def deletions @deletions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/gitlab/git/commit_stats.rb', line 10 def id @id end |
#total ⇒ Object (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
#fetch_stats(repo, commit) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/git/commit_stats.rb', line 25 def fetch_stats(repo, commit) Rails.cache.fetch("commit_stats:#{repo.gl_project_path}:#{@id}") do stats = wrapped_gitaly_errors do repo.gitaly_commit_client.commit_stats(@id) end [stats.additions, stats.deletions] end end |