https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114585

Revision: 114585
Author:   saper
Date:     2012-03-28 22:33:37 +0000 (Wed, 28 Mar 2012)
Log Message:
-----------
Allow Change ID's to be entered into the form

* Properly detect missing URL fragment
* Provide some defaults for changeset numbers

Modified Paths:
--------------
    trunk/tools/gerrit-differ/gerrit-differ.php

Modified: trunk/tools/gerrit-differ/gerrit-differ.php
===================================================================
--- trunk/tools/gerrit-differ/gerrit-differ.php 2012-03-28 22:11:01 UTC (rev 
114584)
+++ trunk/tools/gerrit-differ/gerrit-differ.php 2012-03-28 22:33:37 UTC (rev 
114585)
@@ -72,8 +72,8 @@
                $xw->writeAttribute( 'method', 'POST' );
 
                $this->textBox( 'url', 'Gerrit change URL', 80 );
-               $this->textBox( 'old', 'Old patchset index', 10 );
-               $this->textBox( 'new', 'New patchset index', 10 );
+               $this->textBox( 'old', 'Old patchset index', 10, 1 );
+               $this->textBox( 'new', 'New patchset index', 10, 2 );
                $this->textBox( 'base', 'Rebase branch', 30, 'master' );
 
                $xw->startElement( 'input' );
@@ -135,15 +135,20 @@
                        return;
                }
 
+               $change_id = intval( $url );
+               if ( $change_id > 0 ) {
+                       $url = "https://gerrit.wikimedia.org/r/#change,"; . 
$change_id;
+               }
+
                $fragment = @parse_url( $url, PHP_URL_FRAGMENT );
-               if ( $fragment === false ) {
+               if ( $fragment === null ) {
                        $this->showError( 'Malformed Gerrit URL: no fragment' );
                        return;
                }
 
                $host = @parse_url( $url, PHP_URL_HOST );
                if ( $host !== 'gerrit.wikimedia.org' ) {
-                       $this->showError( 'Sorry, only Wikimedia changes are 
supported at the moment' );
+                       $this->showError( 'Sorry, only Wikimedia changes are 
supported at the moment. You can also enter change ID.');
                        return;
                }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to