Class: ActiveHookFilter

Inherits:
Object
  • Object
show all
Defined in:
app/models/hooks/active_hook_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(hook) ⇒ ActiveHookFilter

Returns a new instance of ActiveHookFilter.


4
5
6
7
# File 'app/models/hooks/active_hook_filter.rb', line 4

def initialize(hook)
  @hook = hook
  @push_events_filter_matcher = RefMatcher.new(@hook.push_events_branch_filter)
end

Instance Method Details

#matches?(hooks_scope, data) ⇒ Boolean

Returns:

  • (Boolean)

9
10
11
12
13
14
15
# File 'app/models/hooks/active_hook_filter.rb', line 9

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