Module: Gitlab::FileHook

Defined in:
lib/gitlab/file_hook.rb

Class Method Summary collapse

Class Method Details

.any?Boolean

Returns:

  • (Boolean)

5
6
7
# File 'lib/gitlab/file_hook.rb', line 5

def self.any?
  dir_glob.any? { |entry| File.file?(entry) }
end

.execute(file, data) ⇒ Object


24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/file_hook.rb', line 24

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 == 0, result.stderr]
rescue => e
  [false, e.message]
end

.execute_all_async(data) ⇒ Object


18
19
20
21
22
# File 'lib/gitlab/file_hook.rb', line 18

def self.execute_all_async(data)
  args = files.map { |file| [file, data] }

  FileHookWorker.bulk_perform_async(args) # rubocop:disable Scalability/BulkPerformWithContext
end

.filesObject


9
10
11
# File 'lib/gitlab/file_hook.rb', line 9

def self.files
  dir_glob.select { |entry| File.file?(entry) }
end