Index: trunk/tools/wikibugs/wikibugs |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | my $contents = <STDIN>; |
16 | 16 | my $output; |
17 | 17 | |
18 | | -my $shash = { |
| 18 | +my $shash = { |
19 | 19 | 'enhancement' => "\00315enhancement\003", |
20 | 20 | 'trivial' => 'trivial', |
21 | 21 | 'minor' => "minor", |
— | — | @@ -25,13 +25,13 @@ |
26 | 26 | }; |
27 | 27 | |
28 | 28 | my $rhash = { |
29 | | - 'WORKSFORME' => "\00314(WFM)\003", |
| 29 | + 'WORKSFORME' => "\00314(WFM)\003", |
30 | 30 | 'INVALID' => "\00314(INVALID)\003", |
31 | 31 | 'DUPLICATE' => "\00314(DUP)\003", |
32 | 32 | 'FIXED' => "\00303(FIXED)\003", |
33 | | - 'WONTFIX' => "\00303(WONTFIX)\003", |
| 33 | + 'WONTFIX' => "\00303(WONTFIX)\003", |
34 | 34 | 'LATER' => "\00306(LATER)\003", |
35 | | - 'REMIND' => "\00306(REMIND)\003" |
| 35 | + 'REMIND' => "\00306(REMIND)\003" |
36 | 36 | }; |
37 | 37 | |
38 | 38 | use Email::MIME; |
— | — | @@ -49,13 +49,25 @@ |
50 | 50 | $/ = ""; |
51 | 51 | # extract and remove the comment section |
52 | 52 | 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; |
58 | 70 | } |
59 | | - |
| 71 | + |
60 | 72 | my @changed_fields = split /\s+/, $mail->header( 'X-Bugzilla-Changed-Fields' ); |
61 | 73 | |
62 | 74 | |
— | — | @@ -71,14 +83,14 @@ |
72 | 84 | } elsif ($subject =~ /\[Bug (\d+)\]\s(.*)/s) { |
73 | 85 | ($bug, $summary, $st) = ($1, $2, "\00303(mod)\003"); |
74 | 86 | } |
75 | | - |
| 87 | + |
76 | 88 | ## Set the URL to the URL found in the message body if available, else construct our own URL |
77 | 89 | my $url = |
78 | 90 | $body =~ /^(http.*\/)show_bug\.cgi\?id=(.*)$/m |
79 | 91 | ? "$1$2" # short URL! |
80 | 92 | : "http://bugzilla.wikimedia.org/show_bug.cgi?id=$bug"; |
81 | 93 | |
82 | | - $summary =~ s/\s+/ /g; |
| 94 | + $summary =~ s/\s+/ /g; |
83 | 95 | |
84 | 96 | # We are going to append stuff to the beginning of $output later. |
85 | 97 | # This stuff is going to contain $st. But we want a chance of changing it first. |
— | — | @@ -96,8 +108,6 @@ |
97 | 109 | } |
98 | 110 | else |
99 | 111 | { |
100 | | - ($haschanges, $user) = (1, $1) if $contents =~ /^(?:.*<)?(\S+)\@\S+>? changed:$/m; |
101 | | - |
102 | 112 | if ($haschanges) { |
103 | 113 | my @outputs; |
104 | 114 | my $status = $mail->header( 'X-Bugzilla-Status' ); |
— | — | @@ -151,7 +161,7 @@ |
152 | 162 | if ($output) |
153 | 163 | { |
154 | 164 | open (OUT, ">>/var/wikibugs/wikibugs.log"); |
155 | | -# print $output; |
| 165 | + # print $output; |
156 | 166 | print OUT $output; |
157 | 167 | close OUT; |
158 | 168 | } |