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

Revision: 114893
Author:   awjrichards
Date:     2012-04-13 22:03:16 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
Abstracted 'git review' stuff into a new method, gerritReviewWrapper in 
perparation for adding capacity for other gerrit review options (eg abandon)

Modified Paths:
--------------
    trunk/tools/gerrit-dippybird/dippy-bird.php

Modified: trunk/tools/gerrit-dippybird/dippy-bird.php
===================================================================
--- trunk/tools/gerrit-dippybird/dippy-bird.php 2012-04-13 21:48:37 UTC (rev 
114892)
+++ trunk/tools/gerrit-dippybird/dippy-bird.php 2012-04-13 22:03:16 UTC (rev 
114893)
@@ -107,6 +107,12 @@
         * @return mixed
         */
        public function executeSubmit( $results ) {
+               $review_opts = '--verified 1 --code-review 2';
+               $action = 'submit';
+               $this->gerritReviewWrapper( $results, $action, $review_opts );
+       }
+
+       protected function gerritReviewWrapper( $results, $action, $review_opts 
= '' ) {
                // If there are less than two items in the array, there are no 
changesets on which to operate
                if ( count( $results ) < 2 ) {
                        // nothing to process
@@ -114,7 +120,7 @@
                }
 
                // prepare to do... stuff
-               $submitted = 0;
+               $num_handled = 0;
                $opts = array( 'port', 'server', 'username' );
                $config_opts = $this->getConfigOptsByArray( $opts );
 
@@ -124,7 +130,7 @@
                // loop through patchsets and submit them one by one
                foreach ( $patchset_ids as $patchset_id ) {
                        // prepare command to execute
-                       $cmd = "ssh -p {$config_opts['port']} 
{$config_opts['username']}@{$config_opts['server']} gerrit review --verified 1 
--code-review 2 --submit $patchset_id";
+                       $cmd = "ssh -p {$config_opts['port']} 
{$config_opts['username']}@{$config_opts['server']} gerrit review 
{$review_opts} --{$action} $patchset_id";
 
                        if ( $this->getConfigOpt( 'verbose' ) ) {
                                echo "Executing: " . $cmd . PHP_EOL;
@@ -134,13 +140,13 @@
                        if ( !$this->getConfigOpt( 'pretend' ) ) {
                                exec( escapeshellcmd( $cmd ), $cmd_results, 
$status );
                                if ( $status !== 0 ) {
-                                       $msg = "Problem executing submit" . 
PHP_EOL;
+                                       $msg = "Problem executing $action" . 
PHP_EOL;
                                        $this->bail( 1, $msg );
                                }
                        }
-                       $submitted++;
+                       $num_handled++;
                }
-               echo "$submitted changesets submitted." . PHP_EOL;
+               echo "$action performed on $num_handled changesets." . PHP_EOL;
        }
 
        /**


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

Reply via email to