branches_controller.rb 845 Bytes
Newer Older
1 2 3 4 5
class Projects::BranchesController < Projects::ApplicationController
  # Authorize
  before_filter :authorize_read_project!
  before_filter :require_non_empty_project

6
  before_filter :authorize_code_access!
7
  before_filter :authorize_push!, only: [:create, :destroy]
8 9 10 11 12

  def index
    @branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30)
  end

13 14 15 16
  def recent
    @branches = @repository.recent_branches
  end

17
  def create
18
    CreateBranchService.new.execute(project, params[:branch_name], params[:ref], current_user)
19 20

    redirect_to project_branches_path(@project)
21 22 23
  end

  def destroy
24
    DeleteBranchService.new.execute(project, params[:id], current_user)
25 26

    respond_to do |format|
27
      format.html { redirect_to project_branches_path(@project) }
28 29 30 31
      format.js { render nothing: true }
    end
  end
end