Allow regular code push for developers if the protected branch allows it.
This commit is contained in:
parent
b7eb0d178e
commit
61b4214e94
2 changed files with 6 additions and 0 deletions
|
@ -470,6 +470,10 @@ class Project < ActiveRecord::Base
|
|||
protected_branches_names.include?(branch_name)
|
||||
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?
|
||||
!(forked_project_link.nil? || forked_project_link.forked_from_project.nil?)
|
||||
end
|
||||
|
|
|
@ -85,6 +85,8 @@ module Gitlab
|
|||
# and we dont allow remove of protected branch
|
||||
elsif newrev == Gitlab::Git::BLANK_SHA
|
||||
:remove_protected_branches
|
||||
elsif project.developers_can_push_to_protected_branch?(branch_name(ref))
|
||||
:push_code
|
||||
else
|
||||
:push_code_to_protected_branches
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue