r89717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89716‎ | r89717 | r89718 >
Date:04:08, 8 June 2011
Author:mah
Status:deferred (Comments)
Tags:
Comment:
Fix Bug #18831 (“Wikibugs should use real name instead of e-mail
prefix when reporting on IRC“) with a patch adapted from MZ's patch to
fix.
Modified paths:
  • /trunk/tools/wikibugs/wikibugs (modified) (history)

Diff [purge]

Index: trunk/tools/wikibugs/wikibugs
@@ -14,7 +14,7 @@
1515 my $contents = <STDIN>;
1616 my $output;
1717
18 -my $shash = {
 18+my $shash = {
1919 'enhancement' => "\00315enhancement\003",
2020 'trivial' => 'trivial',
2121 'minor' => "minor",
@@ -25,13 +25,13 @@
2626 };
2727
2828 my $rhash = {
29 - 'WORKSFORME' => "\00314(WFM)\003",
 29+ 'WORKSFORME' => "\00314(WFM)\003",
3030 'INVALID' => "\00314(INVALID)\003",
3131 'DUPLICATE' => "\00314(DUP)\003",
3232 'FIXED' => "\00303(FIXED)\003",
33 - 'WONTFIX' => "\00303(WONTFIX)\003",
 33+ 'WONTFIX' => "\00303(WONTFIX)\003",
3434 'LATER' => "\00306(LATER)\003",
35 - 'REMIND' => "\00306(REMIND)\003"
 35+ 'REMIND' => "\00306(REMIND)\003"
3636 };
3737
3838 use Email::MIME;
@@ -49,13 +49,25 @@
5050 $/ = "";
5151 # extract and remove the comment section
5252 my ($haschanges, $user);
53 - my $comment = $body =~ s/^--- Comment #\d+ from (?-s:.*?<)?(\S+)\@.*//ms;
54 - if($comment) {
55 - $user = $1;
56 - } else {
57 - $user = 'N/A' # shouldn't be possible'
 53+ my $comment = undef;
 54+ for ($body) {
 55+ # Use fancy lookahead magic to match comments in the form of
 56+ # "Foo <bar@baz.com>" or "bing@boop.com".
 57+ if ( m{^--- Comment #\d+ from (.+) <\S+\@.*}m ) {
 58+ $user = $1;
 59+ } elsif ( m{^(.*) <(\S+)\@\S+> changed:$}m ) {
 60+ # Try to grab the "real name" again.
 61+ $haschanges = 1;
 62+ $user = $1;
 63+ } else {
 64+ # If "real name" isn't available and we didn't get a user from the
 65+ # comment header, just use the "X-Bugzilla-Who" header.
 66+ my @who = split '@', $mail->header( 'X-Bugzilla-Who' );
 67+ $user = $who[0];
 68+ }
 69+ $comment = s/^--- Comment #\d+ from (?-s:.*?<)?(\S+)\@.*//ms;
5870 }
59 -
 71+
6072 my @changed_fields = split /\s+/, $mail->header( 'X-Bugzilla-Changed-Fields' );
6173
6274
@@ -71,14 +83,14 @@
7284 } elsif ($subject =~ /\[Bug (\d+)\]\s(.*)/s) {
7385 ($bug, $summary, $st) = ($1, $2, "\00303(mod)\003");
7486 }
75 -
 87+
7688 ## Set the URL to the URL found in the message body if available, else construct our own URL
7789 my $url =
7890 $body =~ /^(http.*\/)show_bug\.cgi\?id=(.*)$/m
7991 ? "$1$2" # short URL!
8092 : "http://bugzilla.wikimedia.org/show_bug.cgi?id=$bug";
8193
82 - $summary =~ s/\s+/ /g;
 94+ $summary =~ s/\s+/ /g;
8395
8496 # We are going to append stuff to the beginning of $output later.
8597 # This stuff is going to contain $st. But we want a chance of changing it first.
@@ -96,8 +108,6 @@
97109 }
98110 else
99111 {
100 - ($haschanges, $user) = (1, $1) if $contents =~ /^(?:.*<)?(\S+)\@\S+>? changed:$/m;
101 -
102112 if ($haschanges) {
103113 my @outputs;
104114 my $status = $mail->header( 'X-Bugzilla-Status' );
@@ -151,7 +161,7 @@
152162 if ($output)
153163 {
154164 open (OUT, ">>/var/wikibugs/wikibugs.log");
155 -# print $output;
 165+ # print $output;
156166 print OUT $output;
157167 close OUT;
158168 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89718followup r89717 with fixes after testing a couple of couple of cases...mah04:34, 8 June 2011
r92833Followup Bug #18831: Apply MZMcBride's patch do make the regex a...mah00:09, 22 July 2011
r113013Bug 18831 always use real name when available...hashar10:39, 5 March 2012

Comments

#Comment by MZMcBride (talk | contribs)   04:14, 8 June 2011

Status & tagging log