]> nos-oignons.net Git - gestion-adh.git/blobdiff - bin/pre-commit-hook
Next step in pre-commit hook implementation
[gestion-adh.git] / bin / pre-commit-hook
index aa60ccbe37c0832d938113d5625fec358131ee06..fcfb3e91a8fd981c7e970027b5b9507244bd093f 100755 (executable)
@@ -16,7 +16,18 @@ else
 end
 
 def is_valid_subscription?(content)
-  content.length != 0 && YAML.load(content)
+  return false if content.length == 0
+  return false unless content.start_with?("---\n")
+  begin
+    data = YAML.load(content)
+  rescue ArgumentError
+    # Parse error
+    return false
+  end
+  ['name', 'email'].each do |key|
+    return false unless data.include?(key)
+  end
+  true
 end
 
 def is_valid_subscription_file?(file)