diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2021-06-03 11:44:11 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2021-06-08 11:41:05 +0300 |
commit | 4a1ec79c75a826955fc446a00d1568c80b23ebee (patch) | |
tree | be4d79dc14f8b007b3eb1adc76d5b3f5ce73d6cf /ruby | |
parent | 55cb537898bce04e5e44be074a4d3d441e1f62b6 (diff) |
UserRevert: Remove Ruby implementation
This RPC was ported to Go, and the feature flag has been removed. From
14.1 onwards this is dead code. Thus this change removes it.
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/lib/gitaly_server/operations_service.rb | 30 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/repository.rb | 44 |
2 files changed, 0 insertions, 74 deletions
diff --git a/ruby/lib/gitaly_server/operations_service.rb b/ruby/lib/gitaly_server/operations_service.rb index 9aae9b84a..e905828c4 100644 --- a/ruby/lib/gitaly_server/operations_service.rb +++ b/ruby/lib/gitaly_server/operations_service.rb @@ -20,36 +20,6 @@ module GitalyServer Gitaly::UserUpdateBranchResponse.new(pre_receive_error: set_utf8!(ex.message)) end - def user_revert(request, call) - repo = Gitlab::Git::Repository.from_gitaly(request.repository, call) - user = Gitlab::Git::User.from_gitaly(request.user) - commit = Gitlab::Git::Commit.new(repo, request.commit) - start_repository = Gitlab::Git::GitalyRemoteRepository.new(request.start_repository || request.repository, call) - - result = repo.revert( - user: user, - commit: commit, - branch_name: request.branch_name, - message: request.message.dup, - start_branch_name: request.start_branch_name.presence, - start_repository: start_repository, - dry_run: request.dry_run, - timestamp: request.timestamp - ) - - branch_update = branch_update_result(result) - Gitaly::UserRevertResponse.new(branch_update: branch_update) - rescue Gitlab::Git::Repository::CreateTreeError => e - Gitaly::UserRevertResponse.new( - create_tree_error: set_utf8!(e.message), - create_tree_error_code: e.error.upcase - ) - rescue Gitlab::Git::CommitError => e - Gitaly::UserRevertResponse.new(commit_error: set_utf8!(e.message)) - rescue Gitlab::Git::PreReceiveError => e - Gitaly::UserRevertResponse.new(pre_receive_error: set_utf8!(e.message)) - end - # rubocop:disable Metrics/AbcSize def user_rebase_confirmable(session, call) Enumerator.new do |y| diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index 678849def..a05c25757 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -209,37 +209,6 @@ module Gitlab OperationService.new(user, self).update_branch(branch_name, newrev, oldrev, push_options: push_options, transaction: transaction) end - # rubocop:disable Metrics/ParameterLists - def revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false, timestamp: nil) - OperationService.new(user, self).with_branch( - branch_name, - start_branch_name: start_branch_name, - start_repository: start_repository - ) do |start_commit| - - revert_tree_id = check_revert_content(commit, start_commit.sha) - - if dry_run - # At this point the tree has been written to the object database but - # not committed, so we'll leave it to be cleaned up by `gc`. - # - # The response expects a SHA, so just return the starting one. - start_commit.sha - else - committer = user_to_committer(user, timestamp) - - create_commit( - message: message, - author: committer, - committer: committer, - tree: revert_tree_id, - parents: [start_commit.sha] - ) - end - end - end - # rubocop:enable Metrics/ParameterLists - def diff_exists?(sha1, sha2) rugged.diff(sha1, sha2).size.positive? end @@ -499,19 +468,6 @@ module Gitlab output end - def check_revert_content(target_commit, source_sha) - args = [target_commit.sha, source_sha] - args << { mainline: 1 } if target_commit.merge_commit? - - revert_index = rugged.revert_commit(*args) - raise CreateTreeError, :conflict if revert_index.conflicts? - - tree_id = revert_index.write_tree(rugged) - raise CreateTreeError, :empty unless diff_exists?(source_sha, tree_id) - - tree_id - end - def branches_filter(filter: nil, sort_by: nil) branches = rugged.branches.each(filter).map do |rugged_ref| begin |