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
path: root/app
diff options
context:
space:
mode:
authorDuana Saskia <starkcoffee@users.noreply.github.com>2018-09-01 18:55:06 +0300
committerDuana Saskia <starkcoffee@users.noreply.github.com>2018-09-05 14:58:52 +0300
commit9d742e61a79dcc85589598259e2fdac030b7ac00 (patch)
treeb1f0b422eeebbc98a52d2003e7ead78fb504afd6 /app
parentc322976032e45f02b60701ebf244a8a876063078 (diff)
Refactor: move active hook filter to TriggerableHooks
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/triggerable_hooks.rb6
-rw-r--r--app/models/project.rb2
-rw-r--r--app/validators/branch_filter_validator.rb1
3 files changed, 8 insertions, 1 deletions
diff --git a/app/models/concerns/triggerable_hooks.rb b/app/models/concerns/triggerable_hooks.rb
index f55ab2fcaf3..9f2e8b420bc 100644
--- a/app/models/concerns/triggerable_hooks.rb
+++ b/app/models/concerns/triggerable_hooks.rb
@@ -28,6 +28,12 @@ module TriggerableHooks
public_send(trigger) # rubocop:disable GitlabSecurity/PublicSend
end
+ def select_active(hooks_scope, data)
+ select do |hook|
+ ActiveHookFilter.new(hook).matches?(hooks_scope, data)
+ end
+ end
+
private
def triggerable_hooks(hooks)
diff --git a/app/models/project.rb b/app/models/project.rb
index 72a53e1a50d..728bbffd671 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1163,7 +1163,7 @@ class Project < ActiveRecord::Base
def execute_hooks(data, hooks_scope = :push_hooks)
run_after_commit_or_now do
- hooks.hooks_for(hooks_scope).select {|hook| ActiveHookFilter.new(hook).matches?(hooks_scope, data)}.each do |hook|
+ hooks.hooks_for(hooks_scope).select_active(hooks_scope, data).each do |hook|
hook.async_execute(data, hooks_scope.to_s)
end
SystemHooksService.new.execute_hooks(data, hooks_scope)
diff --git a/app/validators/branch_filter_validator.rb b/app/validators/branch_filter_validator.rb
index 0965be3d101..ef482aaaa63 100644
--- a/app/validators/branch_filter_validator.rb
+++ b/app/validators/branch_filter_validator.rb
@@ -16,6 +16,7 @@ class BranchFilterValidator < ActiveModel::EachValidator
if value.present?
value_without_wildcards = value.tr('*', 'x')
+
unless Gitlab::GitRefValidator.validate(value_without_wildcards)
record.errors[attribute] << "is not a valid branch name"
end