]> 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 713cb6fa33c1b98a7e615f6aa6e71b4eebec9c18..fcfb3e91a8fd981c7e970027b5b9507244bd093f 100755 (executable)
@@ -16,9 +16,18 @@ else
 end
 
 def is_valid_subscription?(content)
 end
 
 def is_valid_subscription?(content)
-  content.length != 0 &&
-    content.start_with?("---\n") &&
-    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)
 end
 
 def is_valid_subscription_file?(file)