summaryrefslogtreecommitdiffstats
path: root/tools/git-notify
diff options
context:
space:
mode:
Diffstat (limited to 'tools/git-notify')
-rwxr-xr-xtools/git-notify37
1 files changed, 32 insertions, 5 deletions
diff --git a/tools/git-notify b/tools/git-notify
index ccde4bee..0c2f7395 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -102,6 +102,33 @@ sub xml_escape($)
102 return $str; 102 return $str;
103} 103}
104 104
105# right-justify the left column of "left: right" elements, omit undefined elements
106sub format_table(@)
107{
108 my @lines = @_;
109 my @table;
110 my $max = 0;
111
112 foreach my $line (@lines)
113 {
114 next if not defined $line;
115 my $pos = index($line, ":");
116
117 $max = $pos if $pos > $max;
118 }
119
120 foreach my $line (@lines)
121 {
122 next if not defined $line;
123 my ($left, $right) = split(/: */, $line, 2);
124
125 push @table, (defined $left and defined $right)
126 ? sprintf("%*s: %s", $max + 1, $left, $right)
127 : $line;
128 }
129 return @table;
130}
131
105# format an integer date + timezone as string 132# format an integer date + timezone as string
106# algorithm taken from git's date.c 133# algorithm taken from git's date.c
107sub format_date($$) 134sub format_date($$)
@@ -236,15 +263,15 @@ sub send_commit_notice($$)
236 263
237 return if length($diff) == 0; 264 return if length($diff) == 0;
238 265
239 push @notice, 266 push @notice, format_table(
240 "Module: $repos_name", 267 "Module: $repos_name",
241 "Branch: $ref", 268 "Branch: $ref",
242 "Commit: $obj", 269 "Commit: $obj",
243 $gitweb_url ? "URL: $gitweb_url/?a=commit;h=$obj\n" : "", 270 $gitweb_url ? "URL: $gitweb_url/?a=commit;h=$obj" : undef),
244 "Author: " . $info{"author"}, 271 "Author:" . $info{"author"},
245 "Date: " . format_date($info{"author_date"},$info{"author_tz"}), 272 "Date:" . format_date($info{"author_date"},$info{"author_tz"}),
246 "", 273 "",
247 join "\n", @{$info{"log"}}, 274 @{$info{"log"}},
248 "", 275 "",
249 "---", 276 "---",
250 ""; 277 "";