Status code 404 returned when retrieving non existent branch (issue #2922)

Accessing a repository branch that does not exist returns a 404 error instead
of 200 now. Added a test.
This commit is contained in:
Sebastian Ziebell 2013-02-08 17:04:08 +01:00
parent 2f0a75ab77
commit 40e7846f3e
2 changed files with 6 additions and 0 deletions

View file

@ -230,6 +230,7 @@ module Gitlab
# GET /projects/:id/repository/branches/:branch
get ":id/repository/branches/:branch" do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
error!("Branch does not exist", 404) if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project
end