9 SafeYAML::OPTIONS[:default_mode] = :safe
11 if system('git rev-parse --quiet --verify HEAD >/dev/null')
14 # Initial commit: diff against an empty tree object
15 against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
18 def is_valid_subscription?(content)
19 return false if content.length == 0
20 return false unless content.start_with?("---\n")
30 def is_valid_subscription_file?(file)
31 IO.popen(['git', 'show', ":#{file}"]) do |f|
32 is_valid_subscription?(f.read)
37 IO.popen(['git', 'diff-index', '--cached', '--name-status', against]) do |f|
38 f.readlines.each do |line|
39 status, file = line.strip.split("\t", 2)
40 # Has file been added or modified?
41 if ['A', 'M'].include?(status)
43 if !is_valid_subscription_file?(file)
44 $stderr.puts "Désolé : #{file} n'a pas le bon format !"