summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-08-01 16:48:15 +0100
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-08-04 21:15:26 +0100
commit482d7802cc71280595cad71882bf1b438461e435 (patch)
treeba3258d6cb3f0a0fc848753152e5bd5baccdb0ee /app/models/project.rb
parentedc5f4018e45327421e112de18d53bfbdabd38f9 (diff)
downloadgitlab-ce-482d7802cc71280595cad71882bf1b438461e435.tar.gz
changes default_branch_protection to allow devs_can_merge protection option aswell
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 507813bccf8..16a418d5a3f 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -876,14 +876,8 @@ class Project < ActiveRecord::Base
ProtectedBranch.matching(branch_name, protected_branches: @protected_branches).present?
end
- def developers_can_push_to_protected_branch?(branch_name)
- return true if empty_repo? && !default_branch_protected?
-
- protected_branches.matching(branch_name).any?(&:developers_can_push)
- end
-
- def developers_can_merge_to_protected_branch?(branch_name)
- protected_branches.matching(branch_name).any?(&:developers_can_merge)
+ def user_can_push_to_empty_repo?(user)
+ !default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER
end
def forked?
@@ -1278,7 +1272,8 @@ class Project < ActiveRecord::Base
private
def default_branch_protected?
- current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL
+ current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL ||
+ current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE
end
def authorized_for_user_by_group?(user, min_access_level)