diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2016-03-17 23:16:34 +0300 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2016-03-17 23:16:34 +0300 |
commit | cfb10c103f1298b7c4ec94c76f66445a5969d13f (patch) | |
tree | cac3ba9eab75f74cdae43aaba52061a2c01c859d /app/services/commits | |
parent | f728e4b519bc153534dc9632aa37932e2ac24801 (diff) |
Check push permissions only when pushing directly to target branch.
Diffstat (limited to 'app/services/commits')
-rw-r--r-- | app/services/commits/revert_service.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/services/commits/revert_service.rb b/app/services/commits/revert_service.rb index 9cb918d7a2e..a3c950ede1f 100644 --- a/app/services/commits/revert_service.rb +++ b/app/services/commits/revert_service.rb @@ -9,7 +9,8 @@ module Commits @commit = params[:commit] @create_merge_request = params[:create_merge_request].present? - validate and commit + check_push_permissions unless @create_merge_request + commit rescue Repository::CommitError, Gitlab::Git::Repository::InvalidBlobName, GitHooksService::PreReceiveError, ValidationError, ReversionError => ex error(ex.message) @@ -45,11 +46,11 @@ module Commits end end - def validate + def check_push_permissions allowed = ::Gitlab::GitAccess.new(current_user, project).can_push_to_branch?(@target_branch) unless allowed - raise_error('You are not allowed to push into this branch') + raise ValidationError.new('You are not allowed to push into this branch') end true |