summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/hook_formatter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/github_import/hook_formatter.rb')
-rw-r--r--lib/gitlab/github_import/hook_formatter.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/hook_formatter.rb b/lib/gitlab/github_import/hook_formatter.rb
new file mode 100644
index 00000000000..db1fabaa18a
--- /dev/null
+++ b/lib/gitlab/github_import/hook_formatter.rb
@@ -0,0 +1,23 @@
+module Gitlab
+ module GithubImport
+ class HookFormatter
+ EVENTS = %w[* create delete pull_request push].freeze
+
+ attr_reader :raw
+
+ delegate :id, :name, :active, to: :raw
+
+ def initialize(raw)
+ @raw = raw
+ end
+
+ def config
+ raw.config.attrs
+ end
+
+ def valid?
+ (EVENTS & raw.events).any? && active
+ end
+ end
+ end
+end