BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a56e35e9
Commit
a56e35e9
authored
May 23, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'api-branch-deletion' into 'master'
Api branch deletion Fixes #1127
parents
68942dbb
d575ee3e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
branches.md
doc/api/branches.md
+14
-0
branches.rb
lib/api/branches.rb
+7
-1
branches_spec.rb
spec/requests/api/branches_spec.rb
+22
-1
No files found.
doc/api/branches.md
View file @
a56e35e9
...
...
@@ -199,3 +199,17 @@ Parameters:
"protected"
:
false
}
```
## Delete repository branch
```
DELETE /projects/:id/repository/branches/:branch
```
Parameters:
+
`id`
(required) - The ID of a project
+
`branch`
(required) - The name of the branch
It return 200 if succeed or 405 if failed with error message explaining reason.
lib/api/branches.rb
View file @
a56e35e9
...
...
@@ -94,7 +94,13 @@ module API
# DELETE /projects/:id/repository/branches/:branch
delete
":id/repository/branches/:branch"
do
authorize_push_project
DeleteBranchService
.
new
.
execute
(
user_project
,
params
[
:branch
],
current_user
)
result
=
DeleteBranchService
.
new
.
execute
(
user_project
,
params
[
:branch
],
current_user
)
if
result
[
:state
]
==
:success
true
else
render_api_error!
(
result
[
:message
],
405
)
end
end
end
end
...
...
spec/requests/api/branches_spec.rb
View file @
a56e35e9
...
...
@@ -91,7 +91,6 @@ describe API::API, api: true do
end
end
describe
"POST /projects/:id/repository/branches"
do
it
"should create a new branch"
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
),
...
...
@@ -112,4 +111,26 @@ describe API::API, api: true do
response
.
status
.
should
==
403
end
end
describe
"DELETE /projects/:id/repository/branches/:branch"
do
before
{
Repository
.
any_instance
.
stub
(
rm_branch:
true
)
}
it
"should remove branch"
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/new_design"
,
user
)
response
.
status
.
should
==
200
end
it
"should remove protected branch"
do
project
.
protected_branches
.
create
(
name:
'new_design'
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/new_design"
,
user
)
response
.
status
.
should
==
405
json_response
[
'message'
].
should
==
'Protected branch cant be removed'
end
it
"should not remove HEAD branch"
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/master"
,
user
)
response
.
status
.
should
==
405
json_response
[
'message'
].
should
==
'Cannot remove HEAD branch'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment