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/hooks/active_hook_filter.rb')
-rw-r--r--app/models/hooks/active_hook_filter.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/hooks/active_hook_filter.rb b/app/models/hooks/active_hook_filter.rb
new file mode 100644
index 00000000000..ea046bea368
--- /dev/null
+++ b/app/models/hooks/active_hook_filter.rb
@@ -0,0 +1,14 @@
+class ActiveHookFilter
+ def initialize(hook)
+ @hook = hook
+ @push_events_filter_matcher = RefMatcher.new(@hook.push_events_branch_filter)
+ end
+
+ def matches?(hooks_scope, data)
+ return true if hooks_scope != :push_hooks
+ return true if @hook.push_events_branch_filter.blank?
+
+ branch_name = Gitlab::Git.branch_name(data[:ref])
+ @push_events_filter_matcher.matches?(branch_name)
+ end
+end