mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 20:56:08 +10:00
43 lines
1.2 KiB
Ruby
43 lines
1.2 KiB
Ruby
class Projects::BranchesController < Projects::ApplicationController
|
|
# Authorize
|
|
before_filter :authorize_read_project!
|
|
before_filter :require_non_empty_project
|
|
|
|
before_filter :authorize_code_access!
|
|
before_filter :authorize_push!, only: [:create, :destroy]
|
|
|
|
def index
|
|
@sort = params[:sort] || 'name'
|
|
@branches = @repository.branches_sorted_by(@sort)
|
|
@branches = Kaminari.paginate_array(@branches).page(params[:page]).per(30)
|
|
end
|
|
|
|
def recent
|
|
@branches = @repository.recent_branches
|
|
end
|
|
|
|
def create
|
|
result = CreateBranchService.new.execute(project,
|
|
params[:branch_name],
|
|
params[:ref],
|
|
current_user)
|
|
if result[:status] == :success
|
|
@branch = result[:branch]
|
|
redirect_to project_tree_path(@project, @branch.name)
|
|
else
|
|
@error = result[:message]
|
|
render action: 'new'
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
DeleteBranchService.new.execute(project, params[:id], current_user)
|
|
@branch_name = params[:id]
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to project_branches_path(@project) }
|
|
format.js
|
|
end
|
|
end
|
|
end
|