summaryrefslogtreecommitdiffstats
path: root/tools/git-notify
diff options
context:
space:
mode:
Diffstat (limited to 'tools/git-notify')
-rwxr-xr-xtools/git-notify19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/git-notify b/tools/git-notify
index a786f839..a158e872 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -168,6 +168,11 @@ sub format_table(@)
168 return @table; 168 return @table;
169} 169}
170 170
171# return the gitweb URL of the given commit or undef
172sub gitweb_url($$)
173{
174}
175
171# format an integer date + timezone as string 176# format an integer date + timezone as string
172# algorithm taken from git's date.c 177# algorithm taken from git's date.c
173sub format_date($$) 178sub format_date($$)
@@ -317,6 +322,7 @@ sub send_commit_notice($$)
317 my ($ref,$obj) = @_; 322 my ($ref,$obj) = @_;
318 my %info = get_object_info($obj); 323 my %info = get_object_info($obj);
319 my @notice = (); 324 my @notice = ();
325 my $url;
320 326
321 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree"; 327 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
322 my $diff = join("", <DIFF>); 328 my $diff = join("", <DIFF>);
@@ -324,6 +330,17 @@ sub send_commit_notice($$)
324 330
325 return if length($diff) == 0; 331 return if length($diff) == 0;
326 332
333 if ($gitweb_url)
334 {
335 open REVPARSE, "-|" or exec "git", "rev-parse", "--short", $obj or die "cannot exec git-rev-parse";
336 my $short_obj = <REVPARSE>;
337 close REVPARSE or die $! ? "Cannot execute rev-parse: $!" : "rev-parse exited with status: $?";
338
339 $short_obj = $obj if not defined $short_obj;
340 chomp $short_obj;
341 $url = "$gitweb_url/?a=commit;h=$short_obj";
342 }
343
327 push @notice, format_table( 344 push @notice, format_table(
328 "Module: $repos_name", 345 "Module: $repos_name",
329 "Branch: $ref", 346 "Branch: $ref",
@@ -331,7 +348,7 @@ sub send_commit_notice($$)
331 "Author:" . $info{"author"}, 348 "Author:" . $info{"author"},
332 $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef, 349 $info{"committer"} ne $info{"author"} ? "Committer:" . $info{"committer"} : undef,
333 "Date:" . format_date($info{"author_date"},$info{"author_tz"}), 350 "Date:" . format_date($info{"author_date"},$info{"author_tz"}),
334 $gitweb_url ? "URL: $gitweb_url/?a=commit;h=$obj" : undef), 351 $url ? "URL: $url" : undef),
335 "", 352 "",
336 @{$info{"log"}}, 353 @{$info{"log"}},
337 "", 354 "",