debian-mirror-gitlab/app/models/protected_branch.rb

19 lines
652 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class ProtectedBranch < ActiveRecord::Base
include Gitlab::ShellAdapter
2017-08-17 22:00:37 +05:30
include ProtectedRef
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
protected_ref_access_levels :merge, :push
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
# Check if branch name is marked as protected in the system
def self.protected?(project, ref_name)
return true if project.empty_repo? && default_branch_protected?
2016-08-24 12:49:21 +05:30
2017-08-17 22:00:37 +05:30
self.matching(ref_name, protected_refs: project.protected_branches).present?
2016-08-24 12:49:21 +05:30
end
2017-08-17 22:00:37 +05:30
def self.default_branch_protected?
current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL ||
current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE
2016-08-24 12:49:21 +05:30
end
2014-09-02 18:07:02 +05:30
end