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")
22 data = YAML.load(content)
27 ['name', 'email'].each do |key|
28 return false unless data.include?(key)
33 def is_valid_subscription_file?(file)
34 IO.popen(['git', 'show', ":#{file}"]) do |f|
35 is_valid_subscription?(f.read)
40 IO.popen(['git', 'diff-index', '--cached', '--name-status', against]) do |f|
41 f.readlines.each do |line|
42 status, file = line.strip.split("\t", 2)
43 # Has file been added or modified?
44 if ['A', 'M'].include?(status)
46 if !is_valid_subscription_file?(file)
47 $stderr.puts "Désolé : #{file} n'a pas le bon format !"