Commit a05a2949 authored by Robert Speicher's avatar Robert Speicher

Add plumbing for dry-run cherry-pick and revert

This passes the flag from ChangeService to Repository, which passes it
to Gitlab::Git, then to the Gitaly client, then to Gitaly. It defaults
to `false` at all points, maintaining existing behavior.
parent 8ccd460d
......@@ -852,7 +852,7 @@ class Repository
def revert(
user, commit, branch_name, message,
start_branch_name: nil, start_project: project)
start_branch_name: nil, start_project: project, dry_run: false)
with_cache_hooks do
raw_repository.revert(
......@@ -861,14 +861,15 @@ class Repository
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_project.repository.raw_repository
start_repository: start_project.repository.raw_repository,
dry_run: dry_run
)
end
end
def cherry_pick(
user, commit, branch_name, message,
start_branch_name: nil, start_project: project)
start_branch_name: nil, start_project: project, dry_run: false)
with_cache_hooks do
raw_repository.cherry_pick(
......@@ -877,7 +878,8 @@ class Repository
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_project.repository.raw_repository
start_repository: start_project.repository.raw_repository,
dry_run: dry_run
)
end
end
......
......@@ -22,7 +22,9 @@ module Commits
@branch_name,
message,
start_project: @start_project,
start_branch_name: @start_branch)
start_branch_name: @start_branch,
dry_run: @dry_run
)
rescue Gitlab::Git::Repository::CreateTreeError => ex
act = action.to_s.dasherize
type = @commit.change_type_title(current_user)
......
......@@ -21,6 +21,7 @@ module Commits
@start_sha = params[:start_sha]
@branch_name = params[:branch_name]
@force = params[:force] || false
@dry_run = params[:dry_run] || false
end
def execute
......
......@@ -598,14 +598,15 @@ module Gitlab
end
end
def revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
def revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false)
args = {
user: user,
commit: commit,
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_repository
start_repository: start_repository,
dry_run: dry_run
}
wrapped_gitaly_errors do
......@@ -613,14 +614,15 @@ module Gitlab
end
end
def cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
def cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false)
args = {
user: user,
commit: commit,
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_repository
start_repository: start_repository,
dry_run: dry_run
}
wrapped_gitaly_errors do
......
......@@ -187,24 +187,26 @@ module Gitlab
raise Gitlab::Git::CommitError, e
end
def user_cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
def user_cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false)
call_cherry_pick_or_revert(:cherry_pick,
user: user,
commit: commit,
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_repository)
start_repository: start_repository,
dry_run: dry_run)
end
def user_revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
def user_revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run: false)
call_cherry_pick_or_revert(:revert,
user: user,
commit: commit,
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
start_repository: start_repository)
start_repository: start_repository,
dry_run: dry_run)
end
def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:, push_options: [])
......@@ -390,7 +392,7 @@ module Gitlab
response
end
def call_cherry_pick_or_revert(rpc, user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
def call_cherry_pick_or_revert(rpc, user:, commit:, branch_name:, message:, start_branch_name:, start_repository:, dry_run:)
request_class = "Gitaly::User#{rpc.to_s.camelcase}Request".constantize
request = request_class.new(
......@@ -400,7 +402,8 @@ module Gitlab
branch_name: encode_binary(branch_name),
message: encode_binary(message),
start_branch_name: encode_binary(start_branch_name.to_s),
start_repository: start_repository.gitaly_repository
start_repository: start_repository.gitaly_repository,
dry_run: dry_run
)
response = GitalyClient.call(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment