diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 18:08:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 18:08:41 +0300 |
commit | d47f9d2304dbc3a23bba7fe7a5cd07218eeb41cd (patch) | |
tree | 4b4efa1ccd8246fba2dc9f8816d9d2c0268e9818 /lib/gitlab/file_hook.rb | |
parent | c158fa8d69c704663d289341a014c44c062cda88 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/file_hook.rb')
-rw-r--r-- | lib/gitlab/file_hook.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/gitlab/file_hook.rb b/lib/gitlab/file_hook.rb new file mode 100644 index 00000000000..f886fd10f53 --- /dev/null +++ b/lib/gitlab/file_hook.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Gitlab + module FileHook + def self.any? + plugin_glob.any? { |entry| File.file?(entry) } + end + + def self.files + plugin_glob.select { |entry| File.file?(entry) } + end + + def self.plugin_glob + Dir.glob(Rails.root.join('plugins/*')) + end + + def self.execute_all_async(data) + args = files.map { |file| [file, data] } + + FileHookWorker.bulk_perform_async(args) + end + + def self.execute(file, data) + result = Gitlab::Popen.popen_with_detail([file]) do |stdin| + stdin.write(data.to_json) + end + + exit_status = result.status&.exitstatus + [exit_status.zero?, result.stderr] + rescue => e + [false, e.message] + end + end +end |