diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-07-27 18:40:00 +0400 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-09-03 15:08:35 +0400 |
commit | 551145bc98e257280b615e305d531a44d7aa4131 (patch) | |
tree | 20a853ca41d610247f955a9c8824ba50b18d3220 /app/services/delete_branch_service.rb | |
parent | 7a0e1c7238033b33b7296701bfded56d4ad7f250 (diff) |
Validate branch-names and references in WebUI, API
Add specs for GitRefValidator
Diffstat (limited to 'app/services/delete_branch_service.rb')
-rw-r--r-- | app/services/delete_branch_service.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/services/delete_branch_service.rb b/app/services/delete_branch_service.rb index ce2d8093dff..a94dabcdfc0 100644 --- a/app/services/delete_branch_service.rb +++ b/app/services/delete_branch_service.rb @@ -5,21 +5,21 @@ class DeleteBranchService # No such branch unless branch - return error('No such branch') + return error('No such branch', 404) end if branch_name == repository.root_ref - return error('Cannot remove HEAD branch') + return error('Cannot remove HEAD branch', 405) end # Dont allow remove of protected branch if project.protected_branch?(branch_name) - return error('Protected branch cant be removed') + return error('Protected branch cant be removed', 405) end # Dont allow user to remove branch if he is not allowed to push unless current_user.can?(:push_code, project) - return error('You dont have push access to repo') + return error('You dont have push access to repo', 405) end if repository.rm_branch(branch_name) @@ -30,9 +30,10 @@ class DeleteBranchService end end - def error(message) + def error(message, return_code = 400) { message: message, + return_code: return_code, state: :error } end |