]> nos-oignons.net Git - gestion-adh.git/blob - bin/pre-receive-hook
Finish implenting update-ag-subscribers
[gestion-adh.git] / bin / pre-receive-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 $stdin.readlines.each do |ref_line|
12   old_value, new_value, ref_name = ref_line.rstrip.split(' ', 3)
13   IO.popen(['git', 'diff', '--name-status', "#{old_value}..#{new_value}"]) do |io|
14     NosOignons::Git.handle_modified_files(io) do |file|
15       next unless file.start_with?("#{NosOignons::SUBSCRIPTIONS_ROOT}/")
16       begin
17         NosOignons::Subscription.read_from_git(new_value, file)
18       rescue ArgumentError
19         $stderr.puts "Désolé : #{file} n'a pas le bon format !"
20         exit 1
21       end
22     end
23   end
24 end