gitlab-org--gitlab-foss/app/controllers/projects/protected_branches_controll...

52 lines
1.4 KiB
Ruby
Raw Normal View History

class Projects::ProtectedBranchesController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_admin_project!
layout "project_settings"
2012-02-15 21:51:04 +00:00
def index
2013-12-25 14:12:25 +00:00
@branches = @project.protected_branches.to_a
@protected_branch = @project.protected_branches.new
end
def create
@project.protected_branches.create(protected_branch_params)
redirect_to namespace_project_protected_branches_path(@project.namespace,
@project)
end
def update
protected_branch = @project.protected_branches.find(params[:id])
if protected_branch &&
protected_branch.update_attributes(
2015-12-15 02:53:52 +00:00
developers_can_push: params[:developers_can_push]
)
2014-12-26 14:37:04 +00:00
respond_to do |format|
2015-01-24 01:41:10 +00:00
format.json { render json: protected_branch, status: :ok }
2014-12-26 14:37:04 +00:00
end
else
respond_to do |format|
format.json { render json: protected_branch.errors, status: :unprocessable_entity }
end
end
end
def destroy
2012-02-15 21:51:04 +00:00
@project.protected_branches.find(params[:id]).destroy
respond_to do |format|
format.html { redirect_to namespace_project_protected_branches_path }
format.js { render nothing: true }
2012-02-15 21:51:04 +00:00
end
end
private
def protected_branch_params
params.require(:protected_branch).permit(:name, :developers_can_push)
end
end