2017-01-04 13:43:06 -05:00
|
|
|
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes
|
|
|
|
# in a commit.
|
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class CommitStats
|
|
|
|
attr_reader :id, :additions, :deletions, :total
|
|
|
|
|
|
|
|
# Instantiate a CommitStats object
|
2017-07-12 10:31:36 -04:00
|
|
|
#
|
|
|
|
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/323
|
2017-09-06 06:55:16 -04:00
|
|
|
def initialize(repo, commit)
|
2017-01-04 13:43:06 -05:00
|
|
|
@id = commit.id
|
|
|
|
@additions = 0
|
|
|
|
@deletions = 0
|
|
|
|
@total = 0
|
|
|
|
|
2018-07-03 11:39:08 -04:00
|
|
|
repo.wrapped_gitaly_errors do
|
|
|
|
gitaly_stats(repo, commit)
|
2017-09-06 06:55:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def gitaly_stats(repo, commit)
|
|
|
|
stats = repo.gitaly_commit_client.commit_stats(@id)
|
|
|
|
@additions = stats.additions
|
|
|
|
@deletions = stats.deletions
|
|
|
|
@total = @additions + @deletions
|
|
|
|
end
|
2017-01-04 13:43:06 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|