]> nos-oignons.net Git - gestion-adh.git/blob - bin/pre-commit-hook
Also ensure correctness of membership_fee_paid_on field
[gestion-adh.git] / bin / pre-commit-hook
1 #!/usr/bin/ruby1.9.1
2 #-*- coding: utf-8 -*-
3
4 require 'rubygems'
5 require 'bundler'
6 Bundler.setup
7
8 require 'nos_oignons/git'
9 require 'nos_oignons/subscriptions'
10
11 if system('git rev-parse --quiet --verify HEAD >/dev/null')
12   against = 'HEAD'
13 else
14   # Initial commit: diff against an empty tree object
15   against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
16 end
17
18 IO.popen(['git', 'diff-index', '--cached', '--name-status', against]) do |io|
19   handle_modified_files(io) do |file|
20     next unless file.start_with?("#{SUBSCRIPTIONS_ROOT}/")
21     # Use empty ref to get the index
22     if !is_valid_subscription_file?('', file)
23       $stderr.puts "Désolé : #{file} n'a pas le bon format !"
24       exit 1
25     end
26   end
27 end