diff options
Diffstat (limited to 'lib/api/protected_branches.rb')
-rw-r--r-- | lib/api/protected_branches.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/api/protected_branches.rb b/lib/api/protected_branches.rb index 5af43448727..b562ea7d529 100644 --- a/lib/api/protected_branches.rb +++ b/lib/api/protected_branches.rb @@ -9,7 +9,7 @@ module API before { authorize_admin_project } params do - requires :id, type: String, desc: 'The ID of a project' + requires :id, type: String, desc: "The ID of a project" end resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do desc "Get a project's protected branches" do @@ -19,41 +19,41 @@ module API use :pagination end # rubocop: disable CodeReuse/ActiveRecord - get ':id/protected_branches' do + get ":id/protected_branches" do protected_branches = user_project.protected_branches.preload(:push_access_levels, :merge_access_levels) present paginate(protected_branches), with: Entities::ProtectedBranch, project: user_project end # rubocop: enable CodeReuse/ActiveRecord - desc 'Get a single protected branch' do + desc "Get a single protected branch" do success Entities::ProtectedBranch end params do - requires :name, type: String, desc: 'The name of the branch or wildcard' + requires :name, type: String, desc: "The name of the branch or wildcard" end # rubocop: disable CodeReuse/ActiveRecord - get ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do + get ":id/protected_branches/:name", requirements: BRANCH_ENDPOINT_REQUIREMENTS do protected_branch = user_project.protected_branches.find_by!(name: params[:name]) present protected_branch, with: Entities::ProtectedBranch, project: user_project end # rubocop: enable CodeReuse/ActiveRecord - desc 'Protect a single branch or wildcard' do + desc "Protect a single branch or wildcard" do success Entities::ProtectedBranch end params do - requires :name, type: String, desc: 'The name of the protected branch' + requires :name, type: String, desc: "The name of the protected branch" optional :push_access_level, type: Integer, values: ProtectedBranch::PushAccessLevel.allowed_access_levels, - desc: 'Access levels allowed to push (defaults: `40`, maintainer access level)' + desc: "Access levels allowed to push (defaults: `40`, maintainer access level)" optional :merge_access_level, type: Integer, values: ProtectedBranch::MergeAccessLevel.allowed_access_levels, - desc: 'Access levels allowed to merge (defaults: `40`, maintainer access level)' + desc: "Access levels allowed to merge (defaults: `40`, maintainer access level)" end # rubocop: disable CodeReuse/ActiveRecord - post ':id/protected_branches' do + post ":id/protected_branches" do protected_branch = user_project.protected_branches.find_by(name: params[:name]) if protected_branch conflict!("Protected branch '#{params[:name]}' already exists") @@ -71,12 +71,12 @@ module API end # rubocop: enable CodeReuse/ActiveRecord - desc 'Unprotect a single branch' + desc "Unprotect a single branch" params do - requires :name, type: String, desc: 'The name of the protected branch' + requires :name, type: String, desc: "The name of the protected branch" end # rubocop: disable CodeReuse/ActiveRecord - delete ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do + delete ":id/protected_branches/:name", requirements: BRANCH_ENDPOINT_REQUIREMENTS do protected_branch = user_project.protected_branches.find_by!(name: params[:name]) destroy_conditionally!(protected_branch) do |