Class: Projects::Forks::SyncService
- Inherits:
-
BaseService
- Object
- BaseService
- Projects::Forks::SyncService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/projects/forks/sync_service.rb
Overview
A service for fetching upstream default branch and merging it to the fork’s specified branch.
Constant Summary collapse
- ONGOING_MERGE_ERROR =
'The synchronization did not happen due to another merge in progress'- PROJECT_NOT_A_FORK_ERROR =
'Project is not a fork'- SOURCE_PROJECT_MISSING_ERROR =
'Source project is missing'- TARGET_BRANCH_MISSING_ERROR =
'Target branch is missing'- MergeError =
Class.new(StandardError)
Constants inherited from BaseService
BaseService::UnauthorizedError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, user, target_branch) ⇒ SyncService
constructor
A new instance of SyncService.
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
#initialize(project, user, target_branch) ⇒ SyncService
Returns a new instance of SyncService.
16 17 18 19 20 21 |
# File 'app/services/projects/forks/sync_service.rb', line 16 def initialize(project, user, target_branch) super(project, user) @source_project = project.fork_source @target_branch = target_branch end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/projects/forks/sync_service.rb', line 23 def execute validate_input! execute_service ServiceResponse.success rescue MergeError => e Gitlab::ErrorTracking.log_exception(e, { project_id: project.id, user_id: current_user.id }) ServiceResponse.error(message: e.) ensure details.exclusive_lease.cancel end |