2013-07-16 15:19:07 -04:00
|
|
|
class Projects::BranchesController < Projects::ApplicationController
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
|
|
|
before_filter :authorize_admin_project!, only: [:destroy, :create]
|
|
|
|
|
|
|
|
def index
|
|
|
|
@branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-07-16 17:09:23 -04:00
|
|
|
@project.repository.add_branch(params[:branch_name], params[:ref])
|
|
|
|
|
|
|
|
redirect_to project_branches_path(@project)
|
2013-07-16 15:19:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-07-16 15:43:14 -04:00
|
|
|
branch = @project.repository.branches.find { |branch| branch.name == params[:id] }
|
|
|
|
|
|
|
|
if branch && @project.repository.rm_branch(branch.name)
|
2013-07-16 16:12:52 -04:00
|
|
|
Event.create_rm_ref(@project, current_user, branch)
|
2013-07-16 15:43:14 -04:00
|
|
|
end
|
2013-07-16 15:19:07 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
2013-07-16 17:09:23 -04:00
|
|
|
format.html { redirect_to project_branches_path(@project) }
|
2013-07-16 15:19:07 -04:00
|
|
|
format.js { render nothing: true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|