3 require 'nos_oignons/git'
4 require 'nos_oignons/mailman'
5 require 'nos_oignons/member'
8 # The following class methods are all meant to be called as command-line scripts
11 NosOignons::Member.all.each do |member|
18 MEMBER_MAILING_LIST = 'ag'
19 def update_ag_subscribers!
20 current_emails = NosOignons::Mailman.list_members(MEMBER_MAILING_LIST)
21 uptodate_emails = NosOignons::Member.all.select(&:up_to_date?).collect(&:email)
23 NosOignons::Mailman.add_members(MEMBER_MAILING_LIST, uptodate_emails - current_emails)
24 NosOignons::Mailman.remove_members(MEMBER_MAILING_LIST, current_emails - uptodate_emails)
28 if system('git rev-parse --quiet --verify HEAD >/dev/null')
31 # Initial commit: diff against an empty tree object
32 against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
35 IO.popen(['git', 'diff-index', '--cached', '--name-status', against]) do |io|
36 NosOignons::Git.handle_modified_files(io) do |file|
37 next unless file.start_with?("#{NosOignons::MEMBERS_ROOT}/")
39 # Use empty ref to get the index
40 NosOignons::Member.read_from_git('', file)
42 $stderr.puts "Désolé : #{file} n'a pas le bon format !"
49 def pre_receive_hook!(stdin)
50 stdin.readlines.each do |ref_line|
51 old_value, new_value, ref_name = ref_line.rstrip.split(' ', 3)
52 IO.popen(['git', 'diff', '--name-status', "#{old_value}..#{new_value}"]) do |io|
53 NosOignons::Git.handle_modified_files(io) do |file|
54 next unless file.start_with?("#{NosOignons::MEMBERS_ROOT}/")
56 NosOignons::Member.read_from_git(new_value, file)
58 $stderr.puts "Désolé : #{file} n'a pas le bon format !"