r47432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47431‎ | r47432 | r47433 >
Date:08:21, 18 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
* Support use of release-notes tag
* Tweak heuristics
Modified paths:
  • /trunk/extensions/CodeReview/CodeReleaseNotes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReleaseNotes.php
@@ -67,7 +67,8 @@
6868 $where .= ' OR cr_path = '.$dbr->addQuotes($this->mPath).')';
6969 }
7070 # Select commits within this range...
71 - $res = $dbr->select( 'code_rev', array('cr_message','cr_author','cr_id'),
 71+ $res = $dbr->select( array('code_rev','code_tags'),
 72+ array('cr_message','cr_author','cr_id','ct_tag AS rnotes'),
7273 array(
7374 'cr_repo_id' => $this->mRepo->getId(), // this repo
7475 "cr_status NOT IN('reverted','deferred','fixme')", // not reverted/deferred/fixme
@@ -75,14 +76,17 @@
7677 $where // in range
7778 ),
7879 __METHOD__,
79 - array( 'ORDER BY' => 'cr_id DESC' )
 80+ array( 'ORDER BY' => 'cr_id DESC' ),
 81+ array( 'code_tags' => array('LEFT JOIN', # Tagged for release notes?
 82+ 'ct_repo_id = cr_repo_id AND ct_rev_id = cr_id AND ct_tag = "release-notes"')
 83+ )
8084 );
8185 $wgOut->addHTML( '<ul>' );
8286 # Output any relevant seeming commits...
8387 while( $row = $dbr->fetchObject( $res ) ) {
8488 $summary = htmlspecialchars($row->cr_message);
85 - # Add this commit summary if needed
86 - if( $this->isRelevant( $summary ) ) {
 89+ # Add this commit summary if needed.
 90+ if( $row->rnotes || $this->isRelevant($summary) ) {
8791 # Keep it short if possible...
8892 $summary = $this->shortenSummary( $summary );
8993 # Anything left? (this can happen with some heuristics)
@@ -100,8 +104,8 @@
101105 }
102106
103107 private function shortenSummary( $summary, $first = true ) {
104 - # Asterixs often used as point-by-point bullets
105 - if( strpos($summary,'*') !== false ) {
 108+ # Astericks often used for point-by-point bullets
 109+ if( preg_match('/(^|\n) ?\*/', $summary) ) {
106110 $blurbs = explode('*',$summary);
107111 # Double newlines separate importance generally
108112 } else if( strpos($summary,"\n\n") !== false ) {
@@ -132,7 +136,7 @@
133137 }
134138
135139 // Quick relevance tests (these *should* be over-inclusive a little if anything)
136 - private function isRelevant( $summary ) {
 140+ private function isRelevant( $summary, $whole = true ) {
137141 # Fixed a bug? Mentioned a config var?
138142 if( preg_match( '/\b(bug #?(\d+)|\$[we]g[0-9a-z]{3,50})\b/i', $summary ) )
139143 return true;
@@ -141,13 +145,16 @@
142146 if( mb_strlen($summary) < 40 || $words <= 5 )
143147 return false;
144148 # All caps words (like "BREAKING CHANGE"/magic words)?
145 - # Literals like "'autoconfirmed'"/'"user contributions"'?
146 - if( preg_match( '/\b([A-Z]{8,30}|[\'"]\w+[\'"])\b/', $summary ) )
 149+ if( preg_match( '/\b[A-Z]{7,30}\b/', $summary ) )
147150 return true;
148151 # Random keywords
149152 if( preg_match( '/\b(wiki|HTML\d|CSS\d|UTF-?8|(Apache|PHP|CGI|Java|Perl|Python|\w+SQL) ?\d?\.?\d?)\b/i', $summary ) )
150153 return true;
151 - # Longish summary :)
152 - return ( $words > 35 );
 154+ # Are we looking at the whole summary or an aspect of it?
 155+ if( $whole ) {
 156+ return preg_match('/(^|\n) ?\*/',$summary); # List of items?
 157+ } else {
 158+ return true;
 159+ }
153160 }
154161 }

Status & tagging log