Commit 2bd955961cdb6d0fa7e51e8fbb61581d6b101b05
1 parent
40e7846f
Exists in
master
and in
4 other branches
Changed function to `not_found`.
Instead of using funtion `error!` the function `not_found!` is used to return 404 error. Adjusted documentation accordingly.
Showing
2 changed files
with
4 additions
and
1 deletions
Show diff stats
doc/api/repositories.md
| @@ -79,6 +79,9 @@ Parameters: | @@ -79,6 +79,9 @@ Parameters: | ||
| 79 | } | 79 | } |
| 80 | ``` | 80 | ``` |
| 81 | 81 | ||
| 82 | +Will return status code `200` on success or `404 Not found` if the branch is not available. | ||
| 83 | + | ||
| 84 | + | ||
| 82 | ## Protect a project repository branch | 85 | ## Protect a project repository branch |
| 83 | 86 | ||
| 84 | Protect a single project repository branch. | 87 | Protect a single project repository branch. |
lib/api/projects.rb
| @@ -230,7 +230,7 @@ module Gitlab | @@ -230,7 +230,7 @@ module Gitlab | ||
| 230 | # GET /projects/:id/repository/branches/:branch | 230 | # GET /projects/:id/repository/branches/:branch |
| 231 | get ":id/repository/branches/:branch" do | 231 | get ":id/repository/branches/:branch" do |
| 232 | @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } | 232 | @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } |
| 233 | - error!("Branch does not exist", 404) if @branch.nil? | 233 | + not_found!("Branch does not exist") if @branch.nil? |
| 234 | present @branch, with: Entities::RepoObject, project: user_project | 234 | present @branch, with: Entities::RepoObject, project: user_project |
| 235 | end | 235 | end |
| 236 | 236 |