From 40e7846f3e25b7f679c9dda719c135fca1ef3d5b Mon Sep 17 00:00:00 2001 From: Sebastian Ziebell Date: Fri, 8 Feb 2013 17:04:08 +0100 Subject: 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. --- lib/api/projects.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index a16243aa822..5e4c564c14b 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -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 -- cgit v1.2.1 From 2bd955961cdb6d0fa7e51e8fbb61581d6b101b05 Mon Sep 17 00:00:00 2001 From: Sebastian Ziebell Date: Sat, 9 Feb 2013 20:54:52 +0100 Subject: Changed function to `not_found`. Instead of using funtion `error!` the function `not_found!` is used to return 404 error. Adjusted documentation accordingly. --- lib/api/projects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 5e4c564c14b..d416121a78a 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -230,7 +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? + not_found!("Branch does not exist") if @branch.nil? present @branch, with: Entities::RepoObject, project: user_project end -- cgit v1.2.1