debian-mirror-gitlab/app/models/projects/branch_rule.rb

33 lines
686 B
Ruby
Raw Normal View History

2023-03-17 16:20:25 +05:30
# frozen_string_literal: true
module Projects
class BranchRule
extend Forwardable
attr_reader :project, :protected_branch
def_delegators(:protected_branch, :name, :group, :default_branch?, :created_at, :updated_at)
def initialize(project, protected_branch)
@protected_branch = protected_branch
@project = project
end
def protected?
true
end
def matching_branches_count
branch_names = project.repository.branch_names
matching_branches = protected_branch.matching(branch_names)
matching_branches.count
end
def branch_protection
protected_branch
end
end
end
Projects::BranchRule.prepend_mod