2020-01-16 10:08:41 -05:00
|
|
|
namespace :file_hooks do
|
2020-04-21 11:21:10 -04:00
|
|
|
desc 'Validate existing file hooks'
|
2018-02-19 12:20:53 -05:00
|
|
|
task validate: :environment do
|
2020-04-21 11:21:10 -04:00
|
|
|
puts 'Validating file hooks from /file_hooks and /plugins directories'
|
2018-02-19 12:20:53 -05:00
|
|
|
|
2020-01-16 10:08:41 -05:00
|
|
|
Gitlab::FileHook.files.each do |file|
|
2020-04-27 05:09:51 -04:00
|
|
|
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-01-16 10:08:41 -05:00
|
|
|
success, message = Gitlab::FileHook.execute(file, Gitlab::DataBuilder::Push::SAMPLE_DATA)
|
2018-02-19 12:55:54 -05:00
|
|
|
|
2018-02-28 05:16:23 -05:00
|
|
|
if success
|
|
|
|
puts "* #{file} succeed (zero exit code)."
|
2018-02-19 12:20:53 -05:00
|
|
|
else
|
2018-02-28 05:16:23 -05:00
|
|
|
puts "* #{file} failure (non-zero exit code). #{message}"
|
2018-02-19 12:20:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-02-08 11:14:10 -05:00
|
|
|
end
|