diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-26 09:17:11 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-26 09:17:11 +0300 |
commit | f62f3417227b345be9d3ebef79ec8ae1d98f4718 (patch) | |
tree | 323af3064e85d867dd2f75c4c38f07d262633990 /ruby | |
parent | 7f67ee12d2d218c7e6f01f2f30ced26633b6536c (diff) | |
parent | 66beec1a34f48f9d07deb20de2839c7c21a97b3c (diff) |
Merge branch 'tc-remove-cherry-pick-sidecar' into 'master'
ruby: Remove UserCherryPick implementation
Closes #3281
See merge request gitlab-org/gitaly!3541
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/lib/gitaly_server/operations_service.rb | 30 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/repository.rb | 65 |
2 files changed, 0 insertions, 95 deletions
diff --git a/ruby/lib/gitaly_server/operations_service.rb b/ruby/lib/gitaly_server/operations_service.rb index 463fb0de0..9aae9b84a 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_cherry_pick(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.cherry_pick( - 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::UserCherryPickResponse.new(branch_update: branch_update) - rescue Gitlab::Git::Repository::CreateTreeError => e - Gitaly::UserCherryPickResponse.new( - create_tree_error: set_utf8!(e.message), - create_tree_error_code: e.error.upcase - ) - rescue Gitlab::Git::CommitError => e - Gitaly::UserCherryPickResponse.new(commit_error: set_utf8!(e.message)) - rescue Gitlab::Git::PreReceiveError => e - Gitaly::UserCherryPickResponse.new(pre_receive_error: set_utf8!(e.message)) - end - def user_revert(request, call) repo = Gitlab::Git::Repository.from_gitaly(request.repository, call) user = Gitlab::Git::User.from_gitaly(request.user) diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index 382f0d0cb..678849def 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -240,23 +240,6 @@ module Gitlab end # rubocop:enable Metrics/ParameterLists - # rubocop:disable Metrics/ParameterLists - def cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false, timestamp: nil) - args = { - user: user, - commit: commit, - branch_name: branch_name, - message: message, - start_branch_name: start_branch_name, - start_repository: start_repository, - dry_run: dry_run, - timestamp: timestamp - } - - rugged_cherry_pick(args) - end - # rubocop:enable Metrics/ParameterLists - def diff_exists?(sha1, sha2) rugged.diff(sha1, sha2).size.positive? end @@ -554,54 +537,6 @@ module Gitlab raise GitError, "Could not delete refs #{ref_names}: #{message}" unless status.zero? end - # rubocop:disable Metrics/ParameterLists - def rugged_cherry_pick(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| - - cherry_pick_tree_id = check_cherry_pick_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: { - email: commit.author_email, - name: commit.author_name, - time: commit.authored_date - }, - committer: committer, - tree: cherry_pick_tree_id, - parents: [start_commit.sha] - ) - end - end - end - # rubocop:enable Metrics/ParameterLists - - def check_cherry_pick_content(target_commit, source_sha) - args = [target_commit.sha, source_sha] - args << 1 if target_commit.merge_commit? - - cherry_pick_index = rugged.cherrypick_commit(*args) - raise CreateTreeError, :conflict if cherry_pick_index.conflicts? - - tree_id = cherry_pick_index.write_tree(rugged) - raise CreateTreeError, :empty unless diff_exists?(source_sha, tree_id) - - tree_id - end - def create_commit(params = {}) params[:message].delete!("\r") |