Merge branch 'api-delete-branch-json' into 'master'
Api delete branch json Fixes gitlab/gitlabhq#1478 See merge request !1233
This commit is contained in:
commit
aa75a755ee
|
@ -19,6 +19,7 @@ class Projects::BranchesController < Projects::ApplicationController
|
||||||
def create
|
def create
|
||||||
result = CreateBranchService.new(project, current_user).
|
result = CreateBranchService.new(project, current_user).
|
||||||
execute(params[:branch_name], params[:ref])
|
execute(params[:branch_name], params[:ref])
|
||||||
|
|
||||||
if result[:status] == :success
|
if result[:status] == :success
|
||||||
@branch = result[:branch]
|
@branch = result[:branch]
|
||||||
redirect_to project_tree_path(@project, @branch.name)
|
redirect_to project_tree_path(@project, @branch.name)
|
||||||
|
|
|
@ -211,3 +211,11 @@ Parameters:
|
||||||
|
|
||||||
It return 200 if succeed, 404 if the branch to be deleted does not exist
|
It return 200 if succeed, 404 if the branch to be deleted does not exist
|
||||||
or 400 for other reasons. In case of an error, an explaining message is provided.
|
or 400 for other reasons. In case of an error, an explaining message is provided.
|
||||||
|
|
||||||
|
Success response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"branch_name": "my-removed-branch"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
@ -82,6 +82,7 @@ module API
|
||||||
authorize_push_project
|
authorize_push_project
|
||||||
result = CreateBranchService.new(user_project, current_user).
|
result = CreateBranchService.new(user_project, current_user).
|
||||||
execute(params[:branch_name], params[:ref])
|
execute(params[:branch_name], params[:ref])
|
||||||
|
|
||||||
if result[:status] == :success
|
if result[:status] == :success
|
||||||
present result[:branch],
|
present result[:branch],
|
||||||
with: Entities::RepoObject,
|
with: Entities::RepoObject,
|
||||||
|
@ -104,7 +105,9 @@ module API
|
||||||
execute(params[:branch])
|
execute(params[:branch])
|
||||||
|
|
||||||
if result[:status] == :success
|
if result[:status] == :success
|
||||||
true
|
{
|
||||||
|
branch_name: params[:branch]
|
||||||
|
}
|
||||||
else
|
else
|
||||||
render_api_error!(result[:message], result[:return_code])
|
render_api_error!(result[:message], result[:return_code])
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,6 +146,7 @@ describe API::API, api: true do
|
||||||
it "should remove branch" do
|
it "should remove branch" do
|
||||||
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
|
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
|
json_response['branch_name'].should == branch_name
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return 404 if branch not exists' do
|
it 'should return 404 if branch not exists' do
|
||||||
|
|
Loading…
Reference in New Issue