diff options
Diffstat (limited to 'app/services/validate_new_branch_service.rb')
-rw-r--r-- | app/services/validate_new_branch_service.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/services/validate_new_branch_service.rb b/app/services/validate_new_branch_service.rb index 7d1ed768ee8..f67f9e1800e 100644 --- a/app/services/validate_new_branch_service.rb +++ b/app/services/validate_new_branch_service.rb @@ -5,15 +5,21 @@ class ValidateNewBranchService < BaseService valid_branch = Gitlab::GitRefValidator.validate(branch_name) unless valid_branch - return error('Branch name is invalid') + return error('Branch name is invalid', nil, branch_name) end if project.repository.branch_exists?(branch_name) - return error('Branch already exists') + return error('Branch already exists', nil, branch_name) end success rescue Gitlab::Git::HooksService::PreReceiveError => ex - error(ex.message) + error(ex.message, nil, branch_name) + end + + private + + def error(message, http_status = nil, branch_name = nil) + super(message, http_status).merge(branch_name: branch_name) end end |