summaryrefslogtreecommitdiff
path: root/app/models/hooks/active_hook_filter.rb
blob: 283e2d680f4b2c1b03d68289a9cd4a3071a09e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

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