gitlab-org--gitlab-foss/app/services/protected_branches/create_service.rb

22 lines
505 B
Ruby
Raw Normal View History

module ProtectedBranches
class CreateService < ProtectedBranches::BaseService
attr_reader :protected_branch
def execute
ProtectedBranch.transaction do
@protected_branch = project.protected_branches.new(name: params[:name])
@protected_branch.save!
@protected_branch.create_push_access_level!
@protected_branch.create_merge_access_level!
set_access_levels!
end
true
rescue ActiveRecord::RecordInvalid
false
end
end
end