2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
namespace :file_hooks do
|
2020-04-22 19:07:51 +05:30
|
|
|
desc 'Validate existing file hooks'
|
2018-03-27 19:54:05 +05:30
|
|
|
task validate: :environment do
|
2020-04-22 19:07:51 +05:30
|
|
|
puts 'Validating file hooks from /file_hooks and /plugins directories'
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
Gitlab::FileHook.files.each do |file|
|
2020-05-24 23:13:21 +05:30
|
|
|
if File.dirname(file).ends_with?('plugins')
|
|
|
|
puts 'DEPRECATED: /plugins directory is deprecated and will be removed in 14.0. ' \
|
|
|
|
'Please move your files into /file_hooks directory.'
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
success, message = Gitlab::FileHook.execute(file, Gitlab::DataBuilder::Push::SAMPLE_DATA)
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
if success
|
|
|
|
puts "* #{file} succeed (zero exit code)."
|
|
|
|
else
|
|
|
|
puts "* #{file} failure (non-zero exit code). #{message}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|