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 content.length != 0 &&
20 content.start_with?("---\n") &&
24 def is_valid_subscription_file?(file)
25 IO.popen(['git', 'show', ":#{file}"]) do |f|
26 is_valid_subscription?(f.read)
31 IO.popen(['git', 'diff-index', '--cached', '--name-status', against]) do |f|
32 f.readlines.each do |line|
33 status, file = line.strip.split("\t", 2)
34 # Has file been added or modified?
35 if ['A', 'M'].include?(status)
37 if !is_valid_subscription_file?(file)
38 $stderr.puts "Désolé : #{file} n'a pas le bon format !"