diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-12-20 19:40:56 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2019-01-02 17:31:32 +0300 |
commit | 3a0ae96c0e10154c93e5160b4ee239a5d198d282 (patch) | |
tree | f5f9bca1916f497542f2d52d5f053f9ced1d5bb3 /lib/gitlab/checks | |
parent | 551e84c2cb5bf9a0bd8c339b012d60607383fb3e (diff) |
Don't run single change checks when changes are unknown
When the `changes` passed to `GitAccess` are the literal string `_any`,
which indicates that this is a pre-authorization check, we now check
whether the user can push to any branch in the project in question,
instead of running the per-change check with `oldrev` `_any`, `newrev`
`nil`, and `ref` `nil`.
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r-- | lib/gitlab/checks/push_check.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/gitlab/checks/push_check.rb b/lib/gitlab/checks/push_check.rb index f3a52f09868..91f8d0bdbc8 100644 --- a/lib/gitlab/checks/push_check.rb +++ b/lib/gitlab/checks/push_check.rb @@ -6,7 +6,7 @@ module Gitlab def validate! logger.log_timed("Checking if you are allowed to push...") do unless can_push? - raise GitAccess::UnauthorizedError, 'You are not allowed to push code to this project.' + raise GitAccess::UnauthorizedError, GitAccess::ERROR_MESSAGES[:push_code] end end end @@ -15,7 +15,7 @@ module Gitlab def can_push? user_access.can_do_action?(:push_code) || - user_access.can_push_to_branch?(branch_name) + project.branch_allows_collaboration?(user_access.user, branch_name) end end end |