summaryrefslogtreecommitdiff
path: root/lib/api/branches.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-09-05 16:06:31 +0000
committerDouwe Maan <douwe@gitlab.com>2017-09-05 16:06:31 +0000
commit4c6898bdcf0bff6a0a3b288215271be4e916b27c (patch)
tree13db382a777a55c8220fcbdd85ebf5bf4cedeb03 /lib/api/branches.rb
parentae9b771797cceee76c18376910519e9e71628acc (diff)
parent063e285e6a8c26a95809873fb32fefc54fe9bdb6 (diff)
downloadgitlab-ce-36860-migrate-issues-author.tar.gz
Merge branch 'master' into '36860-migrate-issues-author'36860-migrate-issues-author
# Conflicts: # db/schema.rb
Diffstat (limited to 'lib/api/branches.rb')
-rw-r--r--lib/api/branches.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index a989394ad91..642c1140fcc 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -24,17 +24,22 @@ module API
present paginate(branches), with: Entities::RepoBranch, project: user_project
end
- desc 'Get a single branch' do
- success Entities::RepoBranch
- end
- params do
- requires :branch, type: String, desc: 'The name of the branch'
- end
- get ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
- branch = user_project.repository.find_branch(params[:branch])
- not_found!("Branch") unless branch
+ resource ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ desc 'Get a single branch' do
+ success Entities::RepoBranch
+ end
+ params do
+ requires :branch, type: String, desc: 'The name of the branch'
+ end
+ head do
+ user_project.repository.branch_exists?(params[:branch]) ? status(204) : status(404)
+ end
+ get do
+ branch = user_project.repository.find_branch(params[:branch])
+ not_found!('Branch') unless branch
- present branch, with: Entities::RepoBranch, project: user_project
+ present branch, with: Entities::RepoBranch, project: user_project
+ end
end
# Note: This API will be deprecated in favor of the protected branches API.