Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit 61b4214e authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Allow regular code push for developers if the protected branch allows it.

parent 24df62780007
...@@ -470,6 +470,10 @@ def protected_branch?(branch_name) ...@@ -470,6 +470,10 @@ def protected_branch?(branch_name)
protected_branches_names.include?(branch_name) protected_branches_names.include?(branch_name)
end end
def developers_can_push_to_protected_branch?(branch_name){ |pb| pb.developers_can_push if == branch_name }.compact.first
def forked? def forked?
!(forked_project_link.nil? || forked_project_link.forked_from_project.nil?) !(forked_project_link.nil? || forked_project_link.forked_from_project.nil?)
end end
...@@ -85,6 +85,8 @@ def change_access_check(user, project, change) ...@@ -85,6 +85,8 @@ def change_access_check(user, project, change)
# and we dont allow remove of protected branch # and we dont allow remove of protected branch
elsif newrev == Gitlab::Git::BLANK_SHA elsif newrev == Gitlab::Git::BLANK_SHA
:remove_protected_branches :remove_protected_branches
elsif project.developers_can_push_to_protected_branch?(branch_name(ref))
else else
:push_code_to_protected_branches :push_code_to_protected_branches
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