summaryrefslogtreecommitdiffstats
path: root/tools/git-notify
diff options
context:
space:
mode:
Diffstat (limited to 'tools/git-notify')
-rwxr-xr-xtools/git-notify101
1 files changed, 68 insertions, 33 deletions
diff --git a/tools/git-notify b/tools/git-notify
index ebede1a4..f524fd73 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -325,7 +325,7 @@ sub get_repos_name()
325 return $repos; 325 return $repos;
326} 326}
327 327
328# extract the information from a commit object and return a hash containing the various fields 328# extract the information from a commit or tag object and return a hash containing the various fields
329sub get_object_info($) 329sub get_object_info($)
330{ 330{
331 my $obj = shift; 331 my $obj = shift;
@@ -335,14 +335,21 @@ sub get_object_info($)
335 335
336 $info{"encoding"} = "utf-8"; 336 $info{"encoding"} = "utf-8";
337 337
338 open OBJ, "-|" or exec "git", "cat-file", "commit", $obj or die "cannot run git-cat-file"; 338 open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file";
339 my $type = <TYPE>;
340 chomp $type;
341 close TYPE or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
342
343 open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file";
339 while (<OBJ>) 344 while (<OBJ>)
340 { 345 {
341 chomp; 346 chomp;
342 if ($do_log) { push @log, $_; } 347 if ($do_log)
343 elsif (/^$/) { $do_log = 1; } 348 {
344 elsif (/^encoding (.+)/) { $info{"encoding"} = $1; } 349 last if /^-----BEGIN PGP SIGNATURE-----/;
345 elsif (/^(author|committer) ((.*) (<.*>)) (\d+) ([+-]\d+)$/) 350 push @log, $_;
351 }
352 elsif (/^(author|committer|tagger) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
346 { 353 {
347 $info{$1} = $2; 354 $info{$1} = $2;
348 $info{$1 . "_name"} = $3; 355 $info{$1 . "_name"} = $3;
@@ -350,9 +357,19 @@ sub get_object_info($)
350 $info{$1 . "_date"} = $5; 357 $info{$1 . "_date"} = $5;
351 $info{$1 . "_tz"} = $6; 358 $info{$1 . "_tz"} = $6;
352 } 359 }
360 elsif (/^tag (.+)/)
361 {
362 $info{"tag"} = $1;
363 }
364 elsif (/^encoding (.+)/)
365 {
366 $info{"encoding"} = $1;
367 }
368 elsif (/^$/) { $do_log = 1; }
353 } 369 }
354 close OBJ or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?"; 370 close OBJ or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
355 371
372 $info{"type"} = $type;
356 $info{"log"} = \@log; 373 $info{"log"} = \@log;
357 return %info; 374 return %info;
358} 375}
@@ -385,7 +402,7 @@ sub send_commit_notice($$)
385 my ($ref,$obj) = @_; 402 my ($ref,$obj) = @_;
386 my %info = get_object_info($obj); 403 my %info = get_object_info($obj);
387 my @notice = (); 404 my @notice = ();
388 my $url; 405 my ($url,$subject);
389 406
390 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree"; 407 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
391 my $diff = join("", <DIFF>); 408 my $diff = join("", <DIFF>);
@@ -401,41 +418,57 @@ sub send_commit_notice($$)
401 418
402 $short_obj = $obj if not defined $short_obj; 419 $short_obj = $obj if not defined $short_obj;
403 chomp $short_obj; 420 chomp $short_obj;
404 $url = "$gitweb_url/?a=commit;h=$short_obj"; 421 $url = "$gitweb_url/?a=$info{type};h=$short_obj";
405 } 422 }
406 423
407 push @notice, format_table( 424 if ($info{"type"} eq "tag")
408 "Module: $repos_name",
409 "Branch: $ref",
410 "Commit: $obj",
411 "Author:" . $info{"author"},
412 $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef,
413 "Date:" . format_date($info{"author_date"},$info{"author_tz"}),
414 $url ? "URL: $url" : undef),
415 "",
416 @{$info{"log"}},
417 "",
418 "---",
419 "";
420
421 open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
422 push @notice, join("", <STAT>);
423 close STAT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
424
425 if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
426 { 425 {
427 push @notice, $diff; 426 push @notice, format_table(
427 "Module: $repos_name",
428 "Branch: $ref",
429 "Tag: $obj",
430 "Tagger:" . $info{"tagger"},
431 "Date:" . format_date($info{"tagger_date"},$info{"tagger_tz"}),
432 $url ? "URL: $url" : undef),
433 "",
434 join "\n", @{$info{"log"}};
435
436 $subject = "Tag " . $info{"tag"} . ": " . $info{"tagger_name"};
428 } 437 }
429 else 438 else
430 { 439 {
431 push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url; 440 push @notice, format_table(
441 "Module: $repos_name",
442 "Branch: $ref",
443 "Commit: $obj",
444 "Author:" . $info{"author"},
445 $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef,
446 "Date:" . format_date($info{"author_date"},$info{"author_tz"}),
447 $url ? "URL: $url" : undef),
448 "",
449 @{$info{"log"}},
450 "",
451 "---",
452 "";
453
454 open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
455 push @notice, join("", <STAT>);
456 close STAT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
457
458 if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
459 {
460 push @notice, $diff;
461 }
462 else
463 {
464 push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
465 }
466 $subject = $info{"author_name"};
432 } 467 }
433 468
469 $subject .= ": " . truncate_str(${$info{"log"}}[0],50);
434 $_ = decode($info{"encoding"}, $_) for @notice; 470 $_ = decode($info{"encoding"}, $_) for @notice;
435 471 mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice);
436 mail_notification($commitlist_address,
437 $info{"author_name"} . ": " . truncate_str(${$info{"log"}}[0], 50),
438 "text/plain; charset=UTF-8", @notice);
439 $sent_notices++; 472 $sent_notices++;
440} 473}
441 474
@@ -446,6 +479,8 @@ sub send_cia_notice($$)
446 my %info = get_object_info($commit); 479 my %info = get_object_info($commit);
447 my @cia_text = (); 480 my @cia_text = ();
448 481
482 return if $info{"type"} ne "commit";
483
449 push @cia_text, 484 push @cia_text,
450 "<message>", 485 "<message>",
451 " <generator>", 486 " <generator>",