Class: MergeRequests::MergeToRefService
- Inherits:
-
MergeBaseService
- Object
- BaseService
- IssuableBaseService
- BaseService
- MergeBaseService
- MergeRequests::MergeToRefService
- Extended by:
- Gitlab::Utils::Override
- Defined in:
- app/services/merge_requests/merge_to_ref_service.rb
Overview
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 target branch would have if we used the regular `MergeService`, but without every side-effect that comes with it (MR updates, mails, source branch deletion, etc). This service should be kept idempotent (i.e. can be executed regardless of the `target_ref` current state).
Constant Summary
Constants inherited from MergeBaseService
MergeRequests::MergeBaseService::MergeError
Instance Attribute Summary
Attributes inherited from MergeBaseService
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods included from Gitlab::Utils::Override
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
Methods inherited from MergeBaseService
#hooks_validation_error, #hooks_validation_pass?
Methods included from Gitlab::Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Methods inherited from BaseService
#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_hooks, #hook_data, #inspect, #source_project, #target_project
Methods included from AssignsMergeParams
#assign_allowed_merge_params, included
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Instance Method Details
#execute(merge_request) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/merge_requests/merge_to_ref_service.rb', line 16 def execute(merge_request) @merge_request = merge_request error_check! commit_id = commit raise_error('Conflicts detected during merge') unless commit_id commit = project.commit(commit_id) target_id, source_id = commit.parent_ids success(commit_id: commit.id, target_id: target_id, source_id: source_id) rescue MergeError, ArgumentError => error error(error.) end |