git-notify 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #!/usr/bin/perl -w
  2. #
  3. # Tool to send git commit notifications
  4. #
  5. # Copyright 2005 Alexandre Julliard
  6. # Copyright 2009 Nagios Plugins Development Team
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation; either version 2 of
  11. # the License, or (at your option) any later version.
  12. #
  13. #
  14. # This script is meant to be called from .git/hooks/post-receive.
  15. #
  16. # Usage: git-notify [options] [--] old-sha1 new-sha1 refname
  17. #
  18. # -C Show committer in the body if different from the author
  19. # -c name Send CIA notifications under specified project name
  20. # -m addr Send mail notifications to specified address
  21. # -n max Set max number of individual mails to send
  22. # -r name Set the git repository name
  23. # -s bytes Set the maximum diff size in bytes (-1 for no limit)
  24. # -t file Prevent duplicate notifications by saving state to this file
  25. # -U mask Set the umask for creating the state file
  26. # -u url Set the URL to the gitweb browser
  27. # -i branch If at least one -i is given, report only for specified branches
  28. # -x branch Exclude changes to the specified branch from reports
  29. # -X Exclude merge commits
  30. # -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe)
  31. #
  32. use strict;
  33. use Fcntl ':flock';
  34. use Encode qw(encode decode);
  35. use Cwd 'realpath';
  36. sub git_config($);
  37. sub get_repos_name();
  38. # some parameters you may want to change
  39. # set this to something that takes "-s"
  40. my $mailer = "/usr/bin/mail";
  41. # CIA notification address
  42. my $cia_address = "cia\@cia.navi.cx";
  43. # debug mode
  44. my $debug = 0;
  45. # configuration parameters
  46. # show the committer if different from the author (can be set with the -C option)
  47. my $show_committer = git_config( "notify.showcommitter" );
  48. # base URL of the gitweb repository browser (can be set with the -u option)
  49. my $gitweb_url = git_config( "notify.baseurl" );
  50. # abbreviate the SHA1 name within gitweb URLs (can be set with the -z option)
  51. my $abbreviate_url = git_config( "notify.shorturls" );
  52. # default repository name (can be changed with the -r option)
  53. my $repos_name = git_config( "notify.repository" ) || get_repos_name();
  54. # max size of diffs in bytes (can be changed with the -s option)
  55. my $max_diff_size = git_config( "notify.maxdiff" ) || 10000;
  56. # address for mail notices (can be set with -m option)
  57. my $commitlist_address = git_config( "notify.mail" );
  58. # project name for CIA notices (can be set with -c option)
  59. my $cia_project_name = git_config( "notify.cia" );
  60. # max number of individual notices before falling back to a single global notice (can be set with -n option)
  61. my $max_individual_notices = git_config( "notify.maxnotices" ) || 100;
  62. # branches to include
  63. my @include_list = split /\s+/, git_config( "notify.include" ) || "";
  64. # branches to exclude
  65. my @exclude_list = split /\s+/, git_config( "notify.exclude" ) || "";
  66. # the state file we use (can be set with the -t option)
  67. my $state_file = git_config( "notify.statefile" );
  68. # umask for creating the state file (can be set with -U option)
  69. my $mode_mask = git_config( "notify.umask" ) || 002;
  70. # Extra options to git rev-list
  71. my @revlist_options;
  72. sub usage()
  73. {
  74. print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n";
  75. print " -C Show committer in the body if different from the author\n";
  76. print " -c name Send CIA notifications under specified project name\n";
  77. print " -m addr Send mail notifications to specified address\n";
  78. print " -n max Set max number of individual mails to send\n";
  79. print " -r name Set the git repository name\n";
  80. print " -s bytes Set the maximum diff size in bytes (-1 for no limit)\n";
  81. print " -t file Prevent duplicate notifications by saving state to this file\n";
  82. print " -U mask Set the umask for creating the state file\n";
  83. print " -u url Set the URL to the gitweb browser\n";
  84. print " -i branch If at least one -i is given, report only for specified branches\n";
  85. print " -x branch Exclude changes to the specified branch from reports\n";
  86. print " -X Exclude merge commits\n";
  87. print " -z Try to abbreviate the SHA1 name within gitweb URLs (unsafe)\n";
  88. exit 1;
  89. }
  90. sub xml_escape($)
  91. {
  92. my $str = shift;
  93. $str =~ s/&/&/g;
  94. $str =~ s/</&lt;/g;
  95. $str =~ s/>/&gt;/g;
  96. my @chars = unpack "U*", $str;
  97. $str = join "", map { ($_ > 127) ? sprintf "&#%u;", $_ : chr($_); } @chars;
  98. return $str;
  99. }
  100. # execute git-rev-list(1) with the given parameters and return the output
  101. sub git_rev_list(@)
  102. {
  103. my @args = @_;
  104. my $revlist = [];
  105. my $pid = open REVLIST, "-|";
  106. die "Cannot open pipe: $!" if not defined $pid;
  107. if (!$pid)
  108. {
  109. exec "git", "rev-list", @revlist_options, @args or die "Cannot execute rev-list: $!";
  110. }
  111. while (<REVLIST>)
  112. {
  113. chomp;
  114. die "Invalid commit: $_" if not /^[0-9a-f]{40}$/;
  115. push @$revlist, $_;
  116. }
  117. close REVLIST or die $! ? "Cannot execute rev-list: $!" : "rev-list exited with status: $?";
  118. return $revlist;
  119. }
  120. # append the given commit hashes to the state file
  121. sub save_commits($)
  122. {
  123. my $commits = shift;
  124. open STATE, ">>", $state_file or die "Cannot open $state_file: $!";
  125. flock STATE, LOCK_EX or die "Cannot lock $state_file";
  126. print STATE "$_\n" for @$commits;
  127. flock STATE, LOCK_UN or die "Cannot unlock $state_file";
  128. close STATE or die "Cannot close $state_file: $!";
  129. }
  130. # for the given range, return the new hashes (and append them to the state file)
  131. sub get_new_commits($$)
  132. {
  133. my ($old_sha1, $new_sha1) = @_;
  134. my ($seen, @args);
  135. my $newrevs = [];
  136. @args = ( "^$old_sha1" ) unless $old_sha1 eq '0' x 40;
  137. push @args, $new_sha1, @exclude_list;
  138. my $revlist = git_rev_list(@args);
  139. if (not defined $state_file or not -e $state_file)
  140. {
  141. save_commits(git_rev_list("--all", "--full-history")) if defined $state_file;
  142. return $revlist;
  143. }
  144. open STATE, $state_file or die "Cannot open $state_file: $!";
  145. flock STATE, LOCK_SH or die "Cannot lock $state_file";
  146. while (<STATE>)
  147. {
  148. chomp;
  149. die "Invalid commit: $_" if not /^[0-9a-f]{40}$/;
  150. $seen->{$_} = 1;
  151. }
  152. flock STATE, LOCK_UN or die "Cannot unlock $state_file";
  153. close STATE or die "Cannot close $state_file: $!";
  154. # FIXME: if another git-notify process reads the $state_file at *this*
  155. # point, that process might generate duplicates of our notifications.
  156. save_commits($revlist);
  157. foreach my $commit (@$revlist)
  158. {
  159. push @$newrevs, $commit unless $seen->{$commit};
  160. }
  161. return $newrevs;
  162. }
  163. # truncate the given string if it exceeds the specified number of characters
  164. sub truncate_str($$)
  165. {
  166. my ($str, $max) = @_;
  167. if (length($str) > $max)
  168. {
  169. $str = substr($str, 0, $max);
  170. $str =~ s/\s+\S+$//;
  171. $str .= " ...";
  172. }
  173. return $str;
  174. }
  175. # right-justify the left column of "left: right" elements, omit undefined elements
  176. sub format_table(@)
  177. {
  178. my @lines = @_;
  179. my @table;
  180. my $max = 0;
  181. foreach my $line (@lines)
  182. {
  183. next if not defined $line;
  184. my $pos = index($line, ":");
  185. $max = $pos if $pos > $max;
  186. }
  187. foreach my $line (@lines)
  188. {
  189. next if not defined $line;
  190. my ($left, $right) = split(/: */, $line, 2);
  191. push @table, (defined $left and defined $right)
  192. ? sprintf("%*s: %s", $max + 1, $left, $right)
  193. : $line;
  194. }
  195. return @table;
  196. }
  197. # format an integer date + timezone as string
  198. # algorithm taken from git's date.c
  199. sub format_date($$)
  200. {
  201. my ($time,$tz) = @_;
  202. if ($tz < 0)
  203. {
  204. my $minutes = (-$tz / 100) * 60 + (-$tz % 100);
  205. $time -= $minutes * 60;
  206. }
  207. else
  208. {
  209. my $minutes = ($tz / 100) * 60 + ($tz % 100);
  210. $time += $minutes * 60;
  211. }
  212. return gmtime($time) . sprintf " %+05d", $tz;
  213. }
  214. # fetch a parameter from the git config file
  215. sub git_config($)
  216. {
  217. my ($param) = @_;
  218. open CONFIG, "-|" or exec "git", "config", $param;
  219. my $ret = <CONFIG>;
  220. chomp $ret if $ret;
  221. close CONFIG or $ret = undef;
  222. return $ret;
  223. }
  224. # parse command line options
  225. sub parse_options()
  226. {
  227. while (@ARGV && $ARGV[0] =~ /^-/)
  228. {
  229. my $arg = shift @ARGV;
  230. if ($arg eq '--') { last; }
  231. elsif ($arg eq '-C') { $show_committer = 1; }
  232. elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; }
  233. elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; }
  234. elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; }
  235. elsif ($arg eq '-r') { $repos_name = shift @ARGV; }
  236. elsif ($arg eq '-s') { $max_diff_size = shift @ARGV; }
  237. elsif ($arg eq '-t') { $state_file = shift @ARGV; }
  238. elsif ($arg eq '-U') { $mode_mask = shift @ARGV; }
  239. elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; }
  240. elsif ($arg eq '-i') { push @include_list, shift @ARGV; }
  241. elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; }
  242. elsif ($arg eq '-X') { push @revlist_options, "--no-merges"; }
  243. elsif ($arg eq '-z') { $abbreviate_url = 1; }
  244. elsif ($arg eq '-d') { $debug++; }
  245. else { usage(); }
  246. }
  247. if (@ARGV && $#ARGV != 2) { usage(); }
  248. @exclude_list = map { "^$_"; } @exclude_list;
  249. }
  250. # send an email notification
  251. sub mail_notification($$$@)
  252. {
  253. my ($name, $subject, $content_type, @text) = @_;
  254. $subject = encode("MIME-Q",$subject);
  255. if ($debug)
  256. {
  257. binmode STDOUT, ":utf8";
  258. print "---------------------\n";
  259. print "To: $name\n";
  260. print "Subject: $subject\n";
  261. print "Content-Type: $content_type\n";
  262. print "\n", join("\n", @text), "\n";
  263. }
  264. else
  265. {
  266. my $pid = open MAIL, "|-";
  267. return unless defined $pid;
  268. if (!$pid)
  269. {
  270. exec $mailer, "-s", $subject, "-a", "Content-Type: $content_type", $name or die "Cannot exec $mailer";
  271. }
  272. binmode MAIL, ":utf8";
  273. print MAIL join("\n", @text), "\n";
  274. close MAIL or warn $! ? "Cannot execute $mailer: $!" : "$mailer exited with status: $?";
  275. }
  276. }
  277. # get the default repository name
  278. sub get_repos_name()
  279. {
  280. my $dir = `git rev-parse --git-dir`;
  281. chomp $dir;
  282. my $repos = realpath($dir);
  283. $repos =~ s/(.*?)((\.git\/)?\.git)$/$1/;
  284. $repos =~ s/(.*)\/([^\/]+)\/?$/$2/;
  285. return $repos;
  286. }
  287. # extract the information from a commit or tag object and return a hash containing the various fields
  288. sub get_object_info($)
  289. {
  290. my $obj = shift;
  291. my %info = ();
  292. my @log = ();
  293. my $do_log = 0;
  294. $info{"encoding"} = "utf-8";
  295. open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file";
  296. my $type = <TYPE>;
  297. chomp $type;
  298. close TYPE or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
  299. open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file";
  300. while (<OBJ>)
  301. {
  302. chomp;
  303. if ($do_log)
  304. {
  305. last if /^-----BEGIN PGP SIGNATURE-----/;
  306. push @log, $_;
  307. }
  308. elsif (/^(author|committer|tagger) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
  309. {
  310. $info{$1} = $2;
  311. $info{$1 . "_name"} = $3;
  312. $info{$1 . "_email"} = $4;
  313. $info{$1 . "_date"} = $5;
  314. $info{$1 . "_tz"} = $6;
  315. }
  316. elsif (/^tag (.+)/)
  317. {
  318. $info{"tag"} = $1;
  319. }
  320. elsif (/^encoding (.+)/)
  321. {
  322. $info{"encoding"} = $1;
  323. }
  324. elsif (/^$/) { $do_log = 1; }
  325. }
  326. close OBJ or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
  327. $info{"type"} = $type;
  328. $info{"log"} = \@log;
  329. return %info;
  330. }
  331. # send a ref change notice to a mailing list
  332. sub send_ref_notice($$@)
  333. {
  334. my ($ref, $action, @notice) = @_;
  335. my ($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/);
  336. $reftype =~ s/^head$/branch/;
  337. @notice = (format_table(
  338. "Module: $repos_name",
  339. ($reftype eq "tag" ? "Tag:" : "Branch:") . $refname,
  340. @notice,
  341. ($action ne "removed" and $gitweb_url)
  342. ? "URL: $gitweb_url/?a=shortlog;h=$ref" : undef),
  343. "",
  344. "The $refname $reftype has been $action.");
  345. mail_notification($commitlist_address, "$refname $reftype $action",
  346. "text/plain; charset=us-ascii", @notice);
  347. }
  348. # send a commit notice to a mailing list
  349. sub send_commit_notice($$)
  350. {
  351. my ($ref,$obj) = @_;
  352. my %info = get_object_info($obj);
  353. my @notice = ();
  354. my ($url,$subject,$obj_string);
  355. if ($gitweb_url)
  356. {
  357. if ($abbreviate_url)
  358. {
  359. open REVPARSE, "-|" or exec "git", "rev-parse", "--short", $obj or die "cannot exec git-rev-parse";
  360. $obj_string = <REVPARSE>;
  361. chomp $obj_string if defined $obj_string;
  362. close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?";
  363. }
  364. $obj_string = $obj if not defined $obj_string;
  365. $url = "$gitweb_url/?a=$info{type};h=$obj_string";
  366. }
  367. if ($info{"type"} eq "tag")
  368. {
  369. push @notice, format_table(
  370. "Module: $repos_name",
  371. "Branch: $ref",
  372. "Tag: $obj",
  373. "Tagger:" . $info{"tagger"},
  374. "Date:" . format_date($info{"tagger_date"},$info{"tagger_tz"}),
  375. $url ? "URL: $url" : undef),
  376. "",
  377. join "\n", @{$info{"log"}};
  378. $subject = "Tag " . $info{"tag"} . ": " . $info{"tagger_name"};
  379. }
  380. else
  381. {
  382. push @notice, format_table(
  383. "Module: $repos_name",
  384. "Branch: $ref",
  385. "Commit: $obj",
  386. "Author:" . $info{"author"},
  387. $show_committer && $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef,
  388. "Date:" . format_date($info{"author_date"},$info{"author_tz"}),
  389. $url ? "URL: $url" : undef),
  390. "",
  391. @{$info{"log"}},
  392. "",
  393. "---",
  394. "";
  395. open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
  396. push @notice, join("", <STAT>);
  397. close STAT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
  398. open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
  399. my $diff = join("", <DIFF>);
  400. close DIFF or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
  401. if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
  402. {
  403. push @notice, $diff;
  404. }
  405. else
  406. {
  407. push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj_string" if $gitweb_url;
  408. }
  409. $subject = $info{"author_name"};
  410. }
  411. $subject .= ": " . truncate_str(${$info{"log"}}[0],50);
  412. $_ = decode($info{"encoding"}, $_) for @notice;
  413. mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice);
  414. }
  415. # send a commit notice to the CIA server
  416. sub send_cia_notice($$)
  417. {
  418. my ($ref,$commit) = @_;
  419. my %info = get_object_info($commit);
  420. my @cia_text = ();
  421. return if $info{"type"} ne "commit";
  422. push @cia_text,
  423. "<message>",
  424. " <generator>",
  425. " <name>git-notify script for CIA</name>",
  426. " </generator>",
  427. " <source>",
  428. " <project>" . xml_escape($cia_project_name) . "</project>",
  429. " <module>" . xml_escape($repos_name) . "</module>",
  430. " <branch>" . xml_escape($ref). "</branch>",
  431. " </source>",
  432. " <body>",
  433. " <commit>",
  434. " <revision>" . substr($commit,0,10) . "</revision>",
  435. " <author>" . xml_escape($info{"author"}) . "</author>",
  436. " <log>" . xml_escape(join "\n", @{$info{"log"}}) . "</log>",
  437. " <files>";
  438. open COMMIT, "-|" or exec "git", "diff-tree", "--name-status", "-r", "-M", $commit or die "cannot run git-diff-tree";
  439. while (<COMMIT>)
  440. {
  441. chomp;
  442. if (/^([AMD])\t(.*)$/)
  443. {
  444. my ($action, $file) = ($1, $2);
  445. my %actions = ( "A" => "add", "M" => "modify", "D" => "remove" );
  446. next unless defined $actions{$action};
  447. push @cia_text, " <file action=\"$actions{$action}\">" . xml_escape($file) . "</file>";
  448. }
  449. elsif (/^R\d+\t(.*)\t(.*)$/)
  450. {
  451. my ($old, $new) = ($1, $2);
  452. push @cia_text, " <file action=\"rename\" to=\"" . xml_escape($new) . "\">" . xml_escape($old) . "</file>";
  453. }
  454. }
  455. close COMMIT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
  456. push @cia_text,
  457. " </files>",
  458. $gitweb_url ? " <url>" . xml_escape("$gitweb_url/?a=commit;h=$commit") . "</url>" : "",
  459. " </commit>",
  460. " </body>",
  461. " <timestamp>" . $info{"author_date"} . "</timestamp>",
  462. "</message>";
  463. mail_notification($cia_address, "DeliverXML", "text/xml", @cia_text);
  464. }
  465. # send a global commit notice when there are too many commits for individual mails
  466. sub send_global_notice($$$)
  467. {
  468. my ($ref, $old_sha1, $new_sha1) = @_;
  469. my $notice = git_rev_list("--pretty", "^$old_sha1", "$new_sha1", @exclude_list);
  470. foreach my $rev (@$notice)
  471. {
  472. $rev =~ s/^commit /URL: $gitweb_url\/?a=commit;h=/ if $gitweb_url;
  473. }
  474. mail_notification($commitlist_address, "New commits on branch $ref", "text/plain; charset=UTF-8", @$notice);
  475. }
  476. # send all the notices
  477. sub send_all_notices($$$)
  478. {
  479. my ($old_sha1, $new_sha1, $ref) = @_;
  480. my ($reftype, $refname, $action, @notice);
  481. return if ($ref =~ /^refs\/remotes\//
  482. or (@include_list && !grep {$_ eq $ref} @include_list));
  483. die "The name \"$ref\" doesn't sound like a local branch or tag"
  484. if not (($reftype, $refname) = ($ref =~ /^refs\/(head|tag)s\/(.+)/));
  485. if ($new_sha1 eq '0' x 40)
  486. {
  487. $action = "removed";
  488. @notice = ( "Old SHA1: $old_sha1" );
  489. }
  490. elsif ($old_sha1 eq '0' x 40)
  491. {
  492. $action = "created";
  493. @notice = ( "SHA1: $new_sha1" );
  494. }
  495. elsif ($reftype eq "tag")
  496. {
  497. $action = "updated";
  498. @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" );
  499. }
  500. elsif (not grep( $_ eq $old_sha1, @{ git_rev_list( $new_sha1, "--full-history" ) } ))
  501. {
  502. $action = "rewritten";
  503. @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" );
  504. }
  505. send_ref_notice( $ref, $action, @notice ) if ($commitlist_address and $action);
  506. unless ($reftype eq "tag" or $new_sha1 eq '0' x 40)
  507. {
  508. my $commits = get_new_commits ( $old_sha1, $new_sha1 );
  509. if (@$commits > $max_individual_notices)
  510. {
  511. send_global_notice( $refname, $old_sha1, $new_sha1 ) if $commitlist_address;
  512. }
  513. elsif (@$commits > 0)
  514. {
  515. foreach my $commit (@$commits)
  516. {
  517. send_commit_notice( $refname, $commit ) if $commitlist_address;
  518. send_cia_notice( $refname, $commit ) if $cia_project_name;
  519. }
  520. }
  521. elsif ($commitlist_address)
  522. {
  523. @notice = ( "Old SHA1: $old_sha1", "New SHA1: $new_sha1" );
  524. send_ref_notice( $ref, "modified", @notice );
  525. }
  526. }
  527. }
  528. parse_options();
  529. umask( $mode_mask );
  530. # append repository path to URL
  531. $gitweb_url .= "/$repos_name.git" if $gitweb_url;
  532. if (@ARGV)
  533. {
  534. send_all_notices( $ARGV[0], $ARGV[1], $ARGV[2] );
  535. }
  536. else # read them from stdin
  537. {
  538. while (<>)
  539. {
  540. chomp;
  541. if (/^([0-9a-f]{40}) ([0-9a-f]{40}) (.*)$/) { send_all_notices( $1, $2, $3 ); }
  542. }
  543. }
  544. exit 0;