Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r--app/models/protected_branch.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index 09a0cfc91dc..aebce59a040 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -26,10 +26,16 @@ class ProtectedBranch < ApplicationRecord
end
def self.protected_ref_accessible_to?(ref, user, project:, action:, protected_refs: nil)
- # Maintainers, owners and admins are allowed to create the default branch
+ if project.empty_repo?
+ member_access = project.team.max_member_access(user.id)
- if project.empty_repo? && project.default_branch_protected?
+ # Admins are always allowed to create the default branch
return true if user.admin? || user.can?(:admin_project, project)
+
+ # Developers can push if it is allowed by default branch protection settings
+ if member_access == Gitlab::Access::DEVELOPER && project.initial_push_to_default_branch_allowed_for_developer?
+ return true
+ end
end
super