debian-mirror-gitlab/app/services/protected_branches/create_service.rb

23 lines
504 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module ProtectedBranches
class CreateService < BaseService
2018-03-17 18:26:18 +05:30
def execute(skip_authorization: false)
2018-05-09 12:01:36 +05:30
raise Gitlab::Access::AccessDeniedError unless skip_authorization || authorized?
protected_branch.save
protected_branch
end
def authorized?
can?(current_user, :create_protected_branch, protected_branch)
end
private
2016-09-13 17:45:13 +05:30
2018-05-09 12:01:36 +05:30
def protected_branch
@protected_branch ||= project.protected_branches.new(params)
2016-09-13 17:45:13 +05:30
end
end
end