Index: trunk/extensions/CodeReview/CodeReleaseNotes.php |
— | — | @@ -67,7 +67,8 @@ |
68 | 68 | $where .= ' OR cr_path = '.$dbr->addQuotes($this->mPath).')'; |
69 | 69 | } |
70 | 70 | # 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'), |
72 | 73 | array( |
73 | 74 | 'cr_repo_id' => $this->mRepo->getId(), // this repo |
74 | 75 | "cr_status NOT IN('reverted','deferred','fixme')", // not reverted/deferred/fixme |
— | — | @@ -75,14 +76,17 @@ |
76 | 77 | $where // in range |
77 | 78 | ), |
78 | 79 | __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 | + ) |
80 | 84 | ); |
81 | 85 | $wgOut->addHTML( '<ul>' ); |
82 | 86 | # Output any relevant seeming commits... |
83 | 87 | while( $row = $dbr->fetchObject( $res ) ) { |
84 | 88 | $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) ) { |
87 | 91 | # Keep it short if possible... |
88 | 92 | $summary = $this->shortenSummary( $summary ); |
89 | 93 | # Anything left? (this can happen with some heuristics) |
— | — | @@ -100,8 +104,8 @@ |
101 | 105 | } |
102 | 106 | |
103 | 107 | 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) ) { |
106 | 110 | $blurbs = explode('*',$summary); |
107 | 111 | # Double newlines separate importance generally |
108 | 112 | } else if( strpos($summary,"\n\n") !== false ) { |
— | — | @@ -132,7 +136,7 @@ |
133 | 137 | } |
134 | 138 | |
135 | 139 | // Quick relevance tests (these *should* be over-inclusive a little if anything) |
136 | | - private function isRelevant( $summary ) { |
| 140 | + private function isRelevant( $summary, $whole = true ) { |
137 | 141 | # Fixed a bug? Mentioned a config var? |
138 | 142 | if( preg_match( '/\b(bug #?(\d+)|\$[we]g[0-9a-z]{3,50})\b/i', $summary ) ) |
139 | 143 | return true; |
— | — | @@ -141,13 +145,16 @@ |
142 | 146 | if( mb_strlen($summary) < 40 || $words <= 5 ) |
143 | 147 | return false; |
144 | 148 | # 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 ) ) |
147 | 150 | return true; |
148 | 151 | # Random keywords |
149 | 152 | if( preg_match( '/\b(wiki|HTML\d|CSS\d|UTF-?8|(Apache|PHP|CGI|Java|Perl|Python|\w+SQL) ?\d?\.?\d?)\b/i', $summary ) ) |
150 | 153 | 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 | + } |
153 | 160 | } |
154 | 161 | } |