Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
02aa269e
Commit
02aa269e
authored
Sep 05, 2017
by
blackst0ne
Committed by
Vitaliy @blackst0ne Klachkov
Sep 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add branch existence check to the APIv4 branches via HEAD request
parent
89efaf2a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
10 deletions
+36
-10
changelogs/unreleased/api_branches_head.yml
changelogs/unreleased/api_branches_head.yml
+5
-0
lib/api/branches.rb
lib/api/branches.rb
+15
-10
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+16
-0
No files found.
changelogs/unreleased/api_branches_head.yml
0 → 100644
View file @
02aa269e
---
title
:
Add branch existence check to the APIv4 branches via HEAD request
merge_request
:
13979
author
:
Vitaliy @blackst0ne Klachkov
type
:
added
lib/api/branches.rb
View file @
02aa269e
...
@@ -24,18 +24,23 @@ module API
...
@@ -24,18 +24,23 @@ module API
present
paginate
(
branches
),
with:
Entities
::
RepoBranch
,
project:
user_project
present
paginate
(
branches
),
with:
Entities
::
RepoBranch
,
project:
user_project
end
end
resource
':id/repository/branches/:branch'
,
requirements:
BRANCH_ENDPOINT_REQUIREMENTS
do
desc
'Get a single branch'
do
desc
'Get a single branch'
do
success
Entities
::
RepoBranch
success
Entities
::
RepoBranch
end
end
params
do
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
end
end
get
':id/repository/branches/:branch'
,
requirements:
BRANCH_ENDPOINT_REQUIREMENTS
do
head
do
user_project
.
repository
.
branch_exists?
(
params
[
:branch
])
?
status
(
204
)
:
status
(
404
)
end
get
do
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
not_found!
(
"Branch"
)
unless
branch
not_found!
(
'Branch'
)
unless
branch
present
branch
,
with:
Entities
::
RepoBranch
,
project:
user_project
present
branch
,
with:
Entities
::
RepoBranch
,
project:
user_project
end
end
end
# Note: This API will be deprecated in favor of the protected branches API.
# Note: This API will be deprecated in favor of the protected branches API.
# Note: The internal data model moved from `developers_can_{merge,push}` to `allowed_to_{merge,push}`
# Note: The internal data model moved from `developers_can_{merge,push}` to `allowed_to_{merge,push}`
...
...
spec/requests/api/branches_spec.rb
View file @
02aa269e
...
@@ -75,6 +75,22 @@ describe API::Branches do
...
@@ -75,6 +75,22 @@ describe API::Branches do
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/branches/
#{
branch_name
}
"
}
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/branches/
#{
branch_name
}
"
}
shared_examples_for
'repository branch'
do
shared_examples_for
'repository branch'
do
context
'HEAD request'
do
it
'returns 204 No Content'
do
head
api
(
route
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
204
)
expect
(
response
.
body
).
to
be_empty
end
it
'returns 404 Not Found'
do
head
api
(
"/projects/
#{
project_id
}
/repository/branches/unknown"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
.
body
).
to
be_empty
end
end
it
'returns the repository branch'
do
it
'returns the repository branch'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
...
...
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