summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2019-07-05 13:28:11 +0000
committerDouwe Maan <douwe@gitlab.com>2019-07-05 13:28:11 +0000
commit9d98eb0435751051c4fd5a82b2dfcaa00c81efbe (patch)
tree5675bc757d5286f46f6296588161d4d97ab20e5d /app/services
parent882e798caf5ac29c8f995922ce942cbe7822fc53 (diff)
parent48307fac1ec7cd207fbd53762fd1226a9d6fb1a2 (diff)
downloadgitlab-ce-9d98eb0435751051c4fd5a82b2dfcaa00c81efbe.tar.gz
Merge branch 'create-merge-train-ref-ce' into 'master'
CE Port: Extend `MergeToRefService` to create merge ref from an arbitrary ref See merge request gitlab-org/gitlab-ce!30361
Diffstat (limited to 'app/services')
-rw-r--r--app/services/merge_requests/merge_to_ref_service.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/services/merge_requests/merge_to_ref_service.rb b/app/services/merge_requests/merge_to_ref_service.rb
index efe4dcd6255..0ea50a5dbf5 100644
--- a/app/services/merge_requests/merge_to_ref_service.rb
+++ b/app/services/merge_requests/merge_to_ref_service.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module MergeRequests
- # Performs the merge between source SHA and the target branch. Instead
+ # Performs the merge between source SHA and the target branch or the specified first parent ref. Instead
# of writing the result to the MR target branch, it targets the `target_ref`.
#
# Ideally this should leave the `target_ref` state with the same state the
@@ -56,12 +56,22 @@ module MergeRequests
raise_error(error) if error
end
+ ##
+ # The parameter `target_ref` is where the merge result will be written.
+ # Default is the merge ref i.e. `refs/merge-requests/:iid/merge`.
def target_ref
- merge_request.merge_ref_path
+ params[:target_ref] || merge_request.merge_ref_path
+ end
+
+ ##
+ # The parameter `first_parent_ref` is the main line of the merge commit.
+ # Default is the target branch ref of the merge request.
+ def first_parent_ref
+ params[:first_parent_ref] || merge_request.target_branch_ref
end
def commit
- repository.merge_to_ref(current_user, source, merge_request, target_ref, commit_message)
+ repository.merge_to_ref(current_user, source, merge_request, target_ref, commit_message, first_parent_ref)
rescue Gitlab::Git::PreReceiveError => error
raise MergeError, error.message
end