r82792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82791‎ | r82792 | r82793 >
Date:13:08, 25 February 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Per r82788, factor out bug matching regex
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeCommentLinker.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeReleaseNotes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -3,6 +3,14 @@
44 class CodeRevision {
55
66 /**
 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+ /**
715 * @var CodeRepository
816 */
917 protected $repo;
@@ -476,7 +484,7 @@
477485 // Update bug references table...
478486 $affectedBugs = array();
479487 $m = array();
480 - if ( preg_match_all( '/\bbug ?#?(\d+)\b/', $this->message, $m ) ) {
 488+ if ( preg_match_all( self::BugReference, $this->message, $m ) ) {
481489 $data = array();
482490 foreach ( $m[1] as $bug ) {
483491 $data[] = array(
Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
@@ -25,7 +25,7 @@
2626 array( $this, 'generalLink' ), $text );
2727 $text = preg_replace_callback( '/\br(\d+)\b/',
2828 array( $this, 'messageRevLink' ), $text );
29 - $text = preg_replace_callback( '/\bbug ?#?(\d+)\b/i',
 29+ $text = preg_replace_callback( CodeRevision::BugReference,
3030 array( $this, 'messageBugLink' ), $text );
3131 return $text;
3232 }
Index: trunk/extensions/CodeReview/ui/CodeReleaseNotes.php
@@ -135,12 +135,22 @@
136136 return $summary;
137137 }
138138
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+ */
140146 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) ) {
143149 return true;
144150 }
 151+ #Mentioned a config var?
 152+ if ( preg_match( '/\b\$[we]g[0-9a-z]{3,50}\b/i', $summary ) ) {
 153+ return true;
 154+ }
145155 # Sanity check: summary cannot be *too* short to be useful
146156 $words = str_word_count( $summary );
147157 if ( mb_strlen( $summary ) < 40 || $words <= 5 ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r82797Followup r82792, add back the case insensitive modifier (typically, the one I...reedy15:57, 25 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82788* (bug 27703) CR should parse 'bug#25848'...reedy10:56, 25 February 2011

Comments

#Comment by MaxSem (talk | contribs)   15:40, 25 February 2011

This change makes the regex case-sensitive.

Status & tagging log