Class: MergeRequests::MergeToRefService
- Inherits:
-
MergeBaseService
- Object
- BaseContainerService
- 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 BaseContainerService
#container, #current_user, #group, #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 inherited from BaseService
#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_external_hooks, #execute_group_mention_hooks, #execute_hooks, #handle_assignees_change, #handle_changes, #handle_reviewers_change, #hook_data, #initialize, #inspect, #merge_request_activity_counter, #source_project, #target_project
Methods included from ErrorLogger
Methods included from AssignsMergeParams
#assign_allowed_merge_params, included
Methods inherited from BaseContainerService
#group_container?, #initialize, #namespace_container?, #project_container?, #project_group
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
Constructor Details
This class inherits a constructor from MergeRequests::BaseService
Instance Method Details
#execute(merge_request) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/merge_requests/merge_to_ref_service.rb', line 16 def execute(merge_request) @merge_request = merge_request error_check! commit_id = extracted_merge_to_ref 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 |