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/graphql/types/projects/branch_rule_type.rb')
-rw-r--r--app/graphql/types/projects/branch_rule_type.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/graphql/types/projects/branch_rule_type.rb b/app/graphql/types/projects/branch_rule_type.rb
index e7632c17cca..1afd2cc3fef 100644
--- a/app/graphql/types/projects/branch_rule_type.rb
+++ b/app/graphql/types/projects/branch_rule_type.rb
@@ -8,6 +8,8 @@ module Types
accepts ::ProtectedBranch
authorize :read_protected_branch
+ alias_method :branch_rule, :object
+
field :name,
type: GraphQL::Types::String,
null: false,
@@ -20,6 +22,12 @@ module Types
calls_gitaly: true,
description: "Check if this branch rule protects the project's default branch."
+ field :matching_branches_count,
+ type: GraphQL::Types::Int,
+ null: false,
+ calls_gitaly: true,
+ description: 'Number of existing branches that match this branch rule.'
+
field :branch_protection,
type: Types::BranchRules::BranchProtectionType,
null: false,
@@ -35,6 +43,10 @@ module Types
Types::TimeType,
null: false,
description: 'Timestamp of when the branch rule was last updated.'
+
+ def matching_branches_count
+ branch_rule.matching(branch_rule.project.repository.branch_names).count
+ end
end
end
end