Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-07 01:30:47 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-07 18:59:17 +0300
commit9aabd8fd5ecb4090515db48692f3d064624aec0a (patch)
tree318418b94d97bc846e6e00ed782181cfd26e9487 /lib/gitlab/checks
parent9b27027619580bffeffa88965007c2c29ac9648c (diff)
Limit queries to a user-branch combination
The query becomes a lot simpler if we can check the branch name as well instead of having to load all branch names.
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/change_access.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index 87e9e47b21a..51ba09aa129 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -47,7 +47,7 @@ module Gitlab
protected
def push_checks
- if user_access.cannot_do_action?(:push_to_repo)
+ unless can_push?
raise GitAccess::UnauthorizedError, ERROR_MESSAGES[:push_code]
end
end
@@ -183,6 +183,11 @@ module Gitlab
def commits
@commits ||= project.repository.new_commits(newrev)
end
+
+ def can_push?
+ user_access.can_do_action?(:push_code) ||
+ user_access.can_push_to_branch?(branch_name)
+ end
end
end
end