Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/protected_branches/create_service.rb')
-rw-r--r--app/services/protected_branches/create_service.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/protected_branches/create_service.rb b/app/services/protected_branches/create_service.rb
new file mode 100644
index 00000000000..743f7bd2ce1
--- /dev/null
+++ b/app/services/protected_branches/create_service.rb
@@ -0,0 +1,19 @@
+class ProtectedBranches::CreateService < 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