r94437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94436‎ | r94437 | r94438 >
Date:00:04, 14 August 2011
Author:demon
Status:ok
Tags:
Comment:
More post-commit fixes. MW.org needs a user agent, and Jenkins wants some post data.
Modified paths:
  • /trunk/tools/subversion/hooks/HooksCommon.inc (modified) (history)

Diff [purge]

Index: trunk/tools/subversion/hooks/HooksCommon.inc
@@ -60,7 +60,7 @@
6161 'pingURL' => array(
6262 'http://www.mediawiki.org/w/api.php?action=codeupdate&format=xml&repo=MediaWiki&rev=$REV',
6363 ),
64 - 'pingURL' => array(
 64+ 'pingJenkins' => array(
6565 'http://ci2.tesla.usability.wikimedia.org:8080/subversion/$UUID/notifyCommit?rev=$REV',
6666 ),
6767 );
@@ -106,7 +106,7 @@
107107 */
108108 public function runPostCommitPings() {
109109 foreach( $this->postCommitPings as $ping => $params ) {
110 - call_user_func_array( array( $this, $test ), $params );
 110+ call_user_func_array( array( $this, $ping ), $params );
111111 }
112112 return 0;
113113 }
@@ -116,7 +116,7 @@
117117 *
118118 * @return string
119119 */
120 - private function getLogMessage() {
 120+ protected function getLogMessage() {
121121 $output = null;
122122 $cmd = "{$this->svnlook} log -t '{$this->transaction}' '{$this->repo}'";
123123 exec( $cmd, $output );
@@ -128,7 +128,7 @@
129129 *
130130 * @return string
131131 */
132 - private function getAuthor() {
 132+ protected function getAuthor() {
133133 $output = null;
134134 $cmd = "{$this->svnlook} author -t '{$this->transaction}' '{$this->repo}'";
135135 exec( $cmd, $output );
@@ -140,7 +140,7 @@
141141 *
142142 * @return array filenames are keys and status letters are values
143143 */
144 - private function getCommitList() {
 144+ protected function getCommitList() {
145145 $output = null;
146146 $cmd = "{$this->svnlook} changed -t '{$this->transaction}' '{$this->repo}'";
147147 exec( $cmd, $output );
@@ -161,7 +161,7 @@
162162 * @param $fileTypes array of file types used for filtering
163163 * @return array
164164 */
165 - private function getChangedFiles( array $fileTypes = array() ) {
 165+ protected function getChangedFiles( array $fileTypes = array() ) {
166166 $list = $this->getCommitList();
167167 $files = array();
168168 foreach ( $list as $file => $status ) {
@@ -187,7 +187,7 @@
188188 *
189189 * @return String
190190 */
191 - private function getRepoUUID() {
 191+ protected function getRepoUUID() {
192192 $output = null;
193193 $cmd = "{$this->svnlook} uuid '{$this->repo}'";
194194 exec( $cmd, $output );
@@ -202,7 +202,7 @@
203203 *
204204 * @return bool
205205 */
206 - private function testLogMessageLength( $minLength = 1, $regex = '' ) {
 206+ protected function testLogMessageLength( $minLength = 1, $regex = '' ) {
207207 $msg = trim( $this->getLogMessage() );
208208 $length = strlen( $msg );
209209 if ( $length < $minLength ) {
@@ -223,7 +223,7 @@
224224 * @param $fileTypes array
225225 * @return bool|string
226226 */
227 - private function testPHPLint( $fileTypes ) {
 227+ protected function testPHPLint( $fileTypes ) {
228228 $output = null;
229229 $result = '';
230230 $changedFiles = $this->getChangedFiles( $fileTypes );
@@ -245,7 +245,7 @@
246246 * @param $badUsers array of bad user names
247247 * @return bool|string
248248 */
249 - private function testBadUsers( $badUsers ) {
 249+ protected function testBadUsers( $badUsers ) {
250250 $ourUser = $this->getAuthor();
251251 if( in_array( $ourUser, $badUsers ) ) {
252252 return "Please do not commit as '{$ourUser}', use your real commit name";
@@ -259,7 +259,7 @@
260260 * @param $smtp String SMTP host to use
261261 * @todo Make the CR header less hardcoded
262262 */
263 - private function notifyMailingList( $list, $smtp, $header = '' ) {
 263+ protected function notifyMailingList( $list, $smtp, $header = '' ) {
264264 $cmd = "{$this->svnnotify} --repos-path \"{$this->repo}\" --revision \"{$this->transaction}\""
265265 . " --to \"{$list}\" --smtp {$smtp} --subject-prefix \"SVN: \""
266266 . " --subject-cx --no-first-line --with-diff --user-domain \"svn.wikimedia.org\""
@@ -272,22 +272,32 @@
273273 * @param $ciaScript String Name of the bot script
274274 * @param $acctName String Name of the account with cia.vc
275275 */
276 - private function notifyIRCBot( $ciaScript, $acctName ) {
 276+ protected function notifyIRCBot( $ciaScript, $acctName ) {
277277 exec( "{$ciaScript} \"{$this->repo}\" \"{$this->transaction}\" \"{$acctName}\"" );
278278 }
 279+
 280+ /**
 281+ * Jenkins needs a little more info than a normal ping. So append post data.
 282+ */
 283+ protected function pingJenkins( $url ) {
 284+ $output = null;
 285+ exec( "{$this->svnlook} changed --revision {$this->transaction} {$this->repo}", $output );
 286+ $this->pingUrl( $url, implode( "\n", $output ) );
 287+ }
279288
280289 /**
281290 * Submit a POST request to the given URL
282291 * @param $url String A url to submit revision info to $REV will be replaced
283292 * with the revision number, and $UUID will become the repo unique identifier
284293 */
285 - private function pingURL( $url ) {
 294+ protected function pingURL( $url, $postData = '' ) {
286295 $url = str_replace( array( '$REV', '$UUID' ),
287296 array( $this->transaction, $this->getRepoUUID() ), $url );
288297 $ch = curl_init();
289298 curl_setopt( $ch, CURLOPT_URL,$url );
290299 curl_setopt( $ch, CURLOPT_POST, true );
291 - curl_setopt( $ch, CURLOPT_POSTFIELDS, '' );
 300+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $postData );
 301+ curl_setopt( $ch, CURLOPT_USERAGENT, 'post-commit-cr-hook/0.1' );
292302 curl_exec( $ch );
293303 curl_close( $ch );
294304 }

Status & tagging log