Commit 01fd0f78 authored by Etienne Baqué's avatar Etienne Baqué

Added Deploy Keys on prot branches FF in GitAccess

parent 20837751
......@@ -37,7 +37,6 @@ class ProtectedBranch::PushAccessLevel < ApplicationRecord
end
def enabled_deploy_key_for_user?(deploy_key, user)
DeployKey.with_write_access_for_project(protected_branch.project, deploy_key: deploy_key).any? &&
deploy_key.user_id == user.id
deploy_key.user_id == user.id && DeployKey.with_write_access_for_project(protected_branch.project, deploy_key: deploy_key).any?
end
end
......@@ -319,8 +319,10 @@ module Gitlab
end
def check_change_access!
return if deploy_key? && !deploy_keys_on_protected_branches_enabled?
if changes == ANY
can_push = deploy_key? ||
can_push = (deploy_key? && deploy_keys_on_protected_branches_enabled?) ||
user_can_push? ||
project&.any_branch_allows_collaboration?(user_access.user)
......@@ -447,7 +449,7 @@ module Gitlab
CiAccess.new
elsif user && request_from_ci_build?
BuildAccess.new(user, container: container)
elsif deploy_key?
elsif deploy_key? && deploy_keys_on_protected_branches_enabled?
DeployKeyAccess.new(deploy_key, container: container)
else
UserAccess.new(user, container: container)
......@@ -526,6 +528,10 @@ module Gitlab
def size_checker
container.repository_size_checker
end
def deploy_keys_on_protected_branches_enabled?
Feature.enabled?(:deploy_keys_on_protected_branches, project)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment