summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git-notify77
1 files changed, 22 insertions, 55 deletions
diff --git a/tools/git-notify b/tools/git-notify
index ce013891..1b10f690 100755
--- a/tools/git-notify
+++ b/tools/git-notify
@@ -194,7 +194,7 @@ sub get_repos_name()
194 return $repos; 194 return $repos;
195} 195}
196 196
197# extract the information from a commit or tag object and return a hash containing the various fields 197# extract the information from a commit object and return a hash containing the various fields
198sub get_object_info($) 198sub get_object_info($)
199{ 199{
200 my $obj = shift; 200 my $obj = shift;
@@ -202,21 +202,13 @@ sub get_object_info($)
202 my @log = (); 202 my @log = ();
203 my $do_log = 0; 203 my $do_log = 0;
204 204
205 open TYPE, "-|" or exec "git", "cat-file", "-t", $obj or die "cannot run git-cat-file"; 205 open OBJ, "-|" or exec "git", "cat-file", "commit", $obj or die "cannot run git-cat-file";
206 my $type = <TYPE>;
207 chomp $type;
208 close TYPE;
209
210 open OBJ, "-|" or exec "git", "cat-file", $type, $obj or die "cannot run git-cat-file";
211 while (<OBJ>) 206 while (<OBJ>)
212 { 207 {
213 chomp; 208 chomp;
214 if ($do_log) 209 if ($do_log) { push @log, $_; }
215 { 210 elsif (/^$/) { $do_log = 1; }
216 last if /^-----BEGIN PGP SIGNATURE-----/; 211 elsif (/^(author|committer) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
217 push @log, $_;
218 }
219 elsif (/^(author|committer|tagger) ((.*) (<.*>)) (\d+) ([+-]\d+)$/)
220 { 212 {
221 $info{$1} = $2; 213 $info{$1} = $2;
222 $info{$1 . "_name"} = $3; 214 $info{$1 . "_name"} = $3;
@@ -224,15 +216,9 @@ sub get_object_info($)
224 $info{$1 . "_date"} = $5; 216 $info{$1 . "_date"} = $5;
225 $info{$1 . "_tz"} = $6; 217 $info{$1 . "_tz"} = $6;
226 } 218 }
227 elsif (/^tag (.*)$/)
228 {
229 $info{"tag"} = $1;
230 }
231 elsif (/^$/) { $do_log = 1; }
232 } 219 }
233 close OBJ; 220 close OBJ;
234 221
235 $info{"type"} = $type;
236 $info{"log"} = \@log; 222 $info{"log"} = \@log;
237 return %info; 223 return %info;
238} 224}
@@ -243,24 +229,8 @@ sub send_commit_notice($$)
243 my ($ref,$obj) = @_; 229 my ($ref,$obj) = @_;
244 my %info = get_object_info($obj); 230 my %info = get_object_info($obj);
245 my @notice = (); 231 my @notice = ();
246 my $subject;
247 232
248 if ($info{"type"} eq "tag") 233 push @notice,
249 {
250 push @notice,
251 "Module: $repos_name",
252 "Branch: $ref",
253 "Tag: $obj",
254 $gitweb_url ? "URL: $gitweb_url/?a=tag;h=$obj\n" : "",
255 "Tagger: " . $info{"tagger"},
256 "Date: " . format_date($info{"tagger_date"},$info{"tagger_tz"}),
257 "",
258 join "\n", @{$info{"log"}};
259 $subject = "Tag " . $info{"tag"} . " : " . $info{"tagger_name"} . ": " . ${$info{"log"}}[0];
260 }
261 else
262 {
263 push @notice,
264 "Module: $repos_name", 234 "Module: $repos_name",
265 "Branch: $ref", 235 "Branch: $ref",
266 "Commit: $obj", 236 "Commit: $obj",
@@ -273,27 +243,26 @@ sub send_commit_notice($$)
273 "---", 243 "---",
274 ""; 244 "";
275 245
276 open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree"; 246 open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
277 push @notice, join("", <STAT>); 247 push @notice, join("", <STAT>);
278 close STAT; 248 close STAT;
279
280 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
281 my $diff = join( "", <DIFF> );
282 close DIFF;
283 249
284 if (($max_diff_size == -1) || (length($diff) < $max_diff_size)) 250 open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
285 { 251 my $diff = join( "", <DIFF> );
286 push @notice, $diff; 252 close DIFF;
287 }
288 else
289 {
290 push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
291 }
292 253
293 $subject = $info{"author_name"} . ": " . ${$info{"log"}}[0]; 254 if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
255 {
256 push @notice, $diff;
257 }
258 else
259 {
260 push @notice, "Diff: $gitweb_url/?a=commitdiff;h=$obj" if $gitweb_url;
294 } 261 }
295 262
296 mail_notification($commitlist_address, $subject, "text/plain; charset=UTF-8", @notice); 263 mail_notification($commitlist_address,
264 $info{"author_name"} . ": " . ${$info{"log"}}[0],
265 "text/plain; charset=UTF-8", @notice);
297} 266}
298 267
299# send a commit notice to the CIA server 268# send a commit notice to the CIA server
@@ -303,8 +272,6 @@ sub send_cia_notice($$)
303 my %info = get_object_info($commit); 272 my %info = get_object_info($commit);
304 my @cia_text = (); 273 my @cia_text = ();
305 274
306 return if $info{"type"} ne "commit";
307
308 push @cia_text, 275 push @cia_text,
309 "<message>", 276 "<message>",
310 " <generator>", 277 " <generator>",