summaryrefslogtreecommitdiff
path: root/app/models/hooks/active_hook_filter.rb
blob: ea046bea368206dc16a4668ba7d90a4da80a0a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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