Class: Projects::Forks::SyncService
- Inherits:
-
BaseService
- Object
- BaseService
- Projects::Forks::SyncService
- 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'
- MergeError =
Class.new(StandardError)
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.
11 12 13 14 15 16 17 18 |
# File 'app/services/projects/forks/sync_service.rb', line 11 def initialize(project, user, target_branch) super(project, user) @source_project = project.fork_source @head_sha = project.repository.commit(target_branch).sha @target_branch = target_branch @details = Projects::Forks::Details.new(project, target_branch) end |
Instance Method Details
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/projects/forks/sync_service.rb', line 20 def execute 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 |