提交 61b4214e 编写于 作者: M Marin Jankovski

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

上级 b7eb0d17
...@@ -470,6 +470,10 @@ class Project < ActiveRecord::Base ...@@ -470,6 +470,10 @@ class Project < ActiveRecord::Base
protected_branches_names.include?(branch_name) protected_branches_names.include?(branch_name)
end end
def developers_can_push_to_protected_branch?(branch_name)
protected_branches.map{ |pb| pb.developers_can_push if pb.name == branch_name }.compact.first
end
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 @@ module Gitlab ...@@ -85,6 +85,8 @@ module Gitlab
# 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))
:push_code
else else
:push_code_to_protected_branches :push_code_to_protected_branches
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册