Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -3,6 +3,14 @@ |
4 | 4 | class CodeRevision { |
5 | 5 | |
6 | 6 | /** |
| 7 | + * Regex to match bug mentions in comments, commit summaries, etc |
| 8 | + * |
| 9 | + * Examples: |
| 10 | + * bug 1234, bug1234, bug #1234, bug#1234 |
| 11 | + */ |
| 12 | + const BugReference = '/\bbug ?#?(\d+)\b/'; |
| 13 | + |
| 14 | + /** |
7 | 15 | * @var CodeRepository |
8 | 16 | */ |
9 | 17 | protected $repo; |
— | — | @@ -476,7 +484,7 @@ |
477 | 485 | // Update bug references table... |
478 | 486 | $affectedBugs = array(); |
479 | 487 | $m = array(); |
480 | | - if ( preg_match_all( '/\bbug ?#?(\d+)\b/', $this->message, $m ) ) { |
| 488 | + if ( preg_match_all( self::BugReference, $this->message, $m ) ) { |
481 | 489 | $data = array(); |
482 | 490 | foreach ( $m[1] as $bug ) { |
483 | 491 | $data[] = array( |
Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | array( $this, 'generalLink' ), $text ); |
27 | 27 | $text = preg_replace_callback( '/\br(\d+)\b/', |
28 | 28 | array( $this, 'messageRevLink' ), $text ); |
29 | | - $text = preg_replace_callback( '/\bbug ?#?(\d+)\b/i', |
| 29 | + $text = preg_replace_callback( CodeRevision::BugReference, |
30 | 30 | array( $this, 'messageBugLink' ), $text ); |
31 | 31 | return $text; |
32 | 32 | } |
Index: trunk/extensions/CodeReview/ui/CodeReleaseNotes.php |
— | — | @@ -135,12 +135,22 @@ |
136 | 136 | return $summary; |
137 | 137 | } |
138 | 138 | |
139 | | - // Quick relevance tests (these *should* be over-inclusive a little if anything) |
| 139 | + /** |
| 140 | + * Quick relevance tests (these *should* be over-inclusive a little if anything) |
| 141 | + * |
| 142 | + * @param $summary |
| 143 | + * @param bool $whole |
| 144 | + * @return bool|int |
| 145 | + */ |
140 | 146 | private function isRelevant( $summary, $whole = true ) { |
141 | | - # Fixed a bug? Mentioned a config var? |
142 | | - if ( preg_match( '/\b(bug ?#?(\d+)|\$[we]g[0-9a-z]{3,50})\b/i', $summary ) ) { |
| 147 | + # Mentioned a bug? |
| 148 | + if ( preg_match( CodeRevision::BugReference, $summary) ) { |
143 | 149 | return true; |
144 | 150 | } |
| 151 | + #Mentioned a config var? |
| 152 | + if ( preg_match( '/\b\$[we]g[0-9a-z]{3,50}\b/i', $summary ) ) { |
| 153 | + return true; |
| 154 | + } |
145 | 155 | # Sanity check: summary cannot be *too* short to be useful |
146 | 156 | $words = str_word_count( $summary ); |
147 | 157 | if ( mb_strlen( $summary ) < 40 || $words <= 5 ) { |