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