新增:更改默认分支接口

This commit is contained in:
2023-02-03 13:45:32 +08:00
parent 3f78899c58
commit f2cdba29ea
4 changed files with 72 additions and 4 deletions

View File

@@ -15,6 +15,17 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
@result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token)
end
before_action :require_manager_above, only: [:update_default_branch]
def update_default_branch
@result_object = Api::V1::Projects::Branches::UpdateDefaultBranchService.call(@project, params[:default_branch], current_user&.gitea_token)
if @result_object
return render_ok
else
return render_error('更新默认分支失败!')
end
end
private
def branch_params
params.require(:branch).permit(:new_branch_name, :old_branch_name)