Class: Branches::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- Branches::CreateService
- Defined in:
- app/services/branches/create_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #bulk_create(branches) ⇒ Object
- #execute(branch_name, ref, create_default_branch_if_empty: true) ⇒ Object
-
#initialize(project, user = nil, params = {}) ⇒ CreateService
constructor
A new instance of CreateService.
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 = nil, params = {}) ⇒ CreateService
Returns a new instance of CreateService.
5 6 7 8 9 |
# File 'app/services/branches/create_service.rb', line 5 def initialize(project, user = nil, params = {}) super(project, user, params) @errors = [] end |
Instance Method Details
#bulk_create(branches) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/branches/create_service.rb', line 24 def bulk_create(branches) reset_errors created_branches = branches .then { |branches| only_valid_branches(branches) } .then { |branches| create_branches(branches) } .then { |branches| expire_branches_cache(branches) } return error(errors) if errors.present? success(branches: created_branches) end |
#execute(branch_name, ref, create_default_branch_if_empty: true) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/branches/create_service.rb', line 11 def execute(branch_name, ref, create_default_branch_if_empty: true) result = validate_ref(ref) return result if result[:status] == :error create_default_branch if create_default_branch_if_empty && project.empty_repo? result = branch_validation_service.execute(branch_name) return result if result[:status] == :error create_branch(branch_name, ref) end |