summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-05-15 12:25:51 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-06-11 17:35:13 +0200
commit698515313fe38fb3f85fdeec1efa15e2c8b54cfd (patch)
treef48e87c94ddbd458319168056596e993f38e76b2 /app
parent75797ac3d2b534a1deda48c8450027055a7c721b (diff)
downloadgitlab-ce-698515313fe38fb3f85fdeec1efa15e2c8b54cfd.tar.gz
Fixes rejected pushes from maintainersbvl-fix-maintainer-push-rejected
Before the push git would make a call to `/:namespace/:project/git-receive-pack`. This would perform an access check without a ref. So the `Project#branch_allows_maintainer_push?` would return false. This adjusts `Project#branch_allows_maintainer_push?` to return true when passing no branch name if there are merge requests open that would allow the user to push. The actual check then happens when a call to `/api/v4/internal/allowed` is made from a git hook.
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 9ca733ecd98..57da42adc28 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2139,10 +2139,14 @@ class Project < ActiveRecord::Base
check_access = -> do
next false if empty_repo?
- merge_request = source_of_merge_requests.opened
- .where(allow_collaboration: true)
- .find_by(source_branch: branch_name)
- merge_request&.can_be_merged_by?(user)
+ merge_requests = source_of_merge_requests.opened
+ .where(allow_collaboration: true)
+
+ if branch_name
+ merge_requests.find_by(source_branch: branch_name)&.can_be_merged_by?(user)
+ else
+ merge_requests.any? { |merge_request| merge_request.can_be_merged_by?(user) }
+ end
end
if RequestStore.active?