Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ruby/lib
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2021-04-26 14:59:33 +0300
committerToon Claes <toon@gitlab.com>2021-05-25 18:47:47 +0300
commit66beec1a34f48f9d07deb20de2839c7c21a97b3c (patch)
tree3226d3fbd52f1c4b116746c282beaa33436191d1 /ruby/lib
parent6efcbcba9029a0a16ec30c0b92155d50596503ac (diff)
ruby: Remove UserCherryPick implementation
In [1] the feature flag for the Go implementation is removed, making the Go implementation the only possible code path for handling the UserCherryPick RPC. This was done in version 13.12. In this change, included in 14.0, the Ruby implementation for this RPC is removed, since it's no longer can be called. 1. 4ad92cb47 (operations: Drop GoUserCherryPick feature flag, 2021-04-26) Fixes: https://gitlab.com/gitlab-org/gitaly/-/issues/3281
Diffstat (limited to 'ruby/lib')
-rw-r--r--ruby/lib/gitaly_server/operations_service.rb30
-rw-r--r--ruby/lib/gitlab/git/repository.rb65
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")