From 348a6c1e4708d1cb832b89138d3b57639ff71aed Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 25 Feb 2019 12:22:41 +0100 Subject: Remove unused Ruby implementation for CommitStats Commit stats are new served by Go, and the implementation can be removed from the Ruby sidecar. MR of the Go port: https://gitlab.com/gitlab-org/gitaly/merge_requests/1048 Closes https://gitlab.com/gitlab-org/gitaly/issues/1471 --- ruby/lib/gitaly_server/commit_service.rb | 18 ------------------ ruby/lib/gitlab/git/commit.rb | 10 ---------- ruby/lib/gitlab/git/commit_stats.rb | 27 --------------------------- ruby/spec/lib/gitlab/git/commit_spec.rb | 23 ----------------------- 4 files changed, 78 deletions(-) delete mode 100644 ruby/lib/gitlab/git/commit_stats.rb (limited to 'ruby') diff --git a/ruby/lib/gitaly_server/commit_service.rb b/ruby/lib/gitaly_server/commit_service.rb index e4916ec70..1aed50b3e 100644 --- a/ruby/lib/gitaly_server/commit_service.rb +++ b/ruby/lib/gitaly_server/commit_service.rb @@ -3,24 +3,6 @@ module GitalyServer include Utils include Gitlab::EncodingHelper - # TODO remove in gitlab 12.0, this is implemented in Go now: - # https://gitlab.com/gitlab-org/gitaly/issues/1471 - def commit_stats(request, call) - repo = Gitlab::Git::Repository.from_gitaly(request.repository, call) - revision = request.revision unless request.revision.empty? - - commit = Gitlab::Git::Commit.find(repo, revision) - - # In the odd case that the revision given doesn't exist we need to raise - # an exception. Since GitLab (currently) already does this for us we don't - # expect this to actually happen, just guarding against future code change - raise GRPC::Internal.new("commit not found for revision '#{revision}'") unless commit - - stats = Gitlab::Git::CommitStats.new(repo, commit) - - Gitaly::CommitStatsResponse.new(oid: stats.id, additions: stats.additions, deletions: stats.deletions) - end - def find_commits(request, call) repository = Gitlab::Git::Repository.from_gitaly(request.repository, call) options = { diff --git a/ruby/lib/gitlab/git/commit.rb b/ruby/lib/gitlab/git/commit.rb index c163e9e6e..9a420c04b 100644 --- a/ruby/lib/gitlab/git/commit.rb +++ b/ruby/lib/gitlab/git/commit.rb @@ -133,12 +133,6 @@ module Gitlab diff end - def has_zero_stats? - stats.total.zero? - rescue - true - end - def no_commit_message "--no commit message" end @@ -157,10 +151,6 @@ module Gitlab parent_ids.map { |oid| self.class.find(@repository, oid) }.compact end - def stats - Gitlab::Git::CommitStats.new(@repository, self) - end - def message encode! @message end diff --git a/ruby/lib/gitlab/git/commit_stats.rb b/ruby/lib/gitlab/git/commit_stats.rb deleted file mode 100644 index 1959233e1..000000000 --- a/ruby/lib/gitlab/git/commit_stats.rb +++ /dev/null @@ -1,27 +0,0 @@ -# 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 - # - # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/323 - def initialize(_repo, commit) - @id = commit.id - @additions = 0 - @deletions = 0 - @total = 0 - - rugged_stats(commit) - end - - def rugged_stats(commit) - diff = commit.rugged_diff_from_parent - _files_changed, @additions, @deletions = diff.stat - @total = @additions + @deletions - end - end - end -end diff --git a/ruby/spec/lib/gitlab/git/commit_spec.rb b/ruby/spec/lib/gitlab/git/commit_spec.rb index b46346353..217e226b9 100644 --- a/ruby/spec/lib/gitlab/git/commit_spec.rb +++ b/ruby/spec/lib/gitlab/git/commit_spec.rb @@ -168,29 +168,6 @@ describe Gitlab::Git::Commit do end end - describe '#stats' do - subject { commit.stats } - - describe '#additions' do - subject { super().additions } - it { is_expected.to eq(11) } - end - - describe '#deletions' do - subject { super().deletions } - it { is_expected.to eq(6) } - end - - describe '#total' do - subject { super().total } - it { is_expected.to eq(17) } - end - end - - describe '#has_zero_stats?' do - it { expect(commit.has_zero_stats?).to eq(false) } - end - describe '#to_hash' do let(:hash) { commit.to_hash } subject { hash } -- cgit v1.2.3