diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-07-27 16:40:00 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-09-03 13:08:35 +0200 |
commit | 551145bc98e257280b615e305d531a44d7aa4131 (patch) | |
tree | 20a853ca41d610247f955a9c8824ba50b18d3220 /lib/api/branches.rb | |
parent | 7a0e1c7238033b33b7296701bfded56d4ad7f250 (diff) | |
download | gitlab-ce-551145bc98e257280b615e305d531a44d7aa4131.tar.gz |
Validate branch-names and references in WebUI, API
Add specs for GitRefValidator
Diffstat (limited to 'lib/api/branches.rb')
-rw-r--r-- | lib/api/branches.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index b32a4aa7bc2..4db5f61dd28 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -80,9 +80,17 @@ module API # POST /projects/:id/repository/branches post ":id/repository/branches" do authorize_push_project - @branch = CreateBranchService.new.execute(user_project, params[:branch_name], params[:ref], current_user) - - present @branch, with: Entities::RepoObject, project: user_project + result = CreateBranchService.new.execute(user_project, + params[:branch_name], + params[:ref], + current_user) + if result[:status] == :success + present result[:branch], + with: Entities::RepoObject, + project: user_project + else + render_api_error!(result[:message], 400) + end end # Delete branch @@ -99,7 +107,7 @@ module API if result[:state] == :success true else - render_api_error!(result[:message], 405) + render_api_error!(result[:message], result[:return_code]) end end end |