Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/242332

Change subject: Code cleanup
......................................................................

Code cleanup

- Use https, not ssh
- Simplify checkout command to one step
- Refactor the action extension handling to its own function

Change-Id: I35ea749931ad266653624185583fdcd3f7473434
---
M make-extension-branches/default.conf
M make-extension-branches/make-extension-branches
2 files changed, 42 insertions(+), 48 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/release 
refs/changes/32/242332/1

diff --git a/make-extension-branches/default.conf 
b/make-extension-branches/default.conf
index 0a25916..5393ac6 100644
--- a/make-extension-branches/default.conf
+++ b/make-extension-branches/default.conf
@@ -13,4 +13,4 @@
 
 // Change to 'username@' in local.conf if your shell username is different than
 // your Wikimedia Labs LDAP username
-$conf->extRepoUrlFormat = 'ssh://gerrit.wikimedia.org:29418/{repository}.git';
+$conf->extRepoUrlFormat = 'https://gerrit.wikimedia.org/r/p/{repository}.git';
diff --git a/make-extension-branches/make-extension-branches 
b/make-extension-branches/make-extension-branches
index af5dada..3d3e16e 100755
--- a/make-extension-branches/make-extension-branches
+++ b/make-extension-branches/make-extension-branches
@@ -82,56 +82,50 @@
        public function start() {
                $this->setup();
                $this->setupBuildDirectory();
-
-               $branchName = $this->opts->branchName;
-               foreach ( $this->conf->extRepos as $extRepo ) {
-                       // Move back to the build dir in each loop,
-                       // otherwise we'll get build/AntiBot/CategoryTree/.. 
instead of build/AntiBot, build/CategoryTree, ..
-                       $this->chdir( $this->buildDir );
-
-                       if ( $extRepo === 'mediawiki/extensions' ) {
-                               // Skip the meta repository
-                               continue;
-                       }
-                       echo "... $extRepo\n";
-                       $url = str_replace( '{repository}', $extRepo, 
$this->conf->extRepoUrlFormat );
-                       $name = basename( $extRepo );
-                       $this->execCmd( 'git', 'clone', '-q', $url, '-b', 
'master', $name );
-                       $this->chdir( $name );
-
-                       $out = $exitcode = null;
-                       // Check if the branch exists already
-                       exec( 'git show-branch origin/' . escapeshellarg( 
$branchName ) . ' 2>&1', $out, $exitcode );
-                       if ( $exitcode == 0 ) {
-                               echo "Skipping $extRepo: Branch exists 
already\n";
-                               continue;
-                       }
-                       $commit = $this->execReadCmd( 'git', 'rev-list', '-n', 
'1', '--before', $this->opts->branchDate, 'master' );
-                       if ( !$commit ) {
-                               echo "Skipping $extRepo: Repo does not have a 
commit before the branch date\n";
-                               continue;
-                       }
-                       if ( $this->conf->verbose ) {
-                               echo "... $extRepo: Branching $branchName at 
$commit\n";
-                       }
-                       $this->execCmd( 'git', 'checkout', '-q', $commit );
-                       exec( 'git branch ' . escapeshellarg( $branchName ) . ' 
2>&1', $out, $exitcode );
-                       if ( $exitcode != 0 ) {
-                               echo "Skipping $extRepo: Creating branch failed 
(exit code: $exitcode)\n";
-                               continue;
-                       }
-
-                       # Intermediate commit & fixes
-                       $this->fixGitReview( $branchName );
-                       $this->execWriteCmd( 'git', 'commit', '-a', '-q', '-m', 
"Creating new {$branchName} branch" );
-
-                       # Final push to repo for this extension
-                       $this->execWriteCmd( 'git', 'push', 'origin', 
"$branchName:refs/heads/$branchName" );
-               }
-
+               array_walk( $this->conf->extRepos, array( $this, 'doExt' ), 
$this->opts->branchName );
                echo "Done!\n";
        }
 
+
+       public function doExt( $extRepo, $unusedKey, $branchName ) {
+               // Move back to the build dir in each loop,
+               // otherwise we'll get build/AntiBot/CategoryTree/.. instead of 
build/AntiBot, build/CategoryTree, ..
+               $this->chdir( $this->buildDir );
+               if ( $extRepo === 'mediawiki/extensions' ) {
+                       // Skip the meta repository
+                       return;
+               }
+               echo "... $extRepo\n";
+               $url = str_replace( '{repository}', $extRepo, 
$this->conf->extRepoUrlFormat );
+               $name = basename( $extRepo );
+               $this->execCmd( 'git', 'clone', '-q', $url, '-b', 'master', 
$name );
+               $this->chdir( $name );
+
+               $out = $exitcode = null;
+               // Check if the branch exists already
+               exec( 'git show-branch origin/' . escapeshellarg( $branchName ) 
. ' 2>&1', $out, $exitcode );
+               if ( $exitcode == 0 ) {
+                       echo "Skipping $extRepo: Branch exists already\n";
+                       return;
+               }
+               $commit = $this->execReadCmd( 'git', 'rev-list', '-n', '1', 
'--before', $this->opts->branchDate, 'master' );
+               if ( !$commit ) {
+                       echo "Skipping $extRepo: Repo does not have a commit 
before the branch date\n";
+                       return;
+               }
+               if ( $this->conf->verbose ) {
+                       echo "... $extRepo: Branching $branchName at $commit\n";
+               }
+               $this->execCmd( 'git', 'checkout', '-q', '-b', $branchName, 
$commit );
+
+               # Intermediate commit & fixes
+               $this->fixGitReview( $branchName );
+               $this->execCmd( 'git', 'commit', '-a', '-q', '-m', "Creating 
new {$branchName} branch" );
+
+               # Final push to repo for this extension
+               $this->execWriteCmd( 'git', 'push', 'origin', 
"$branchName:refs/heads/$branchName" );
+       }
+
        protected function setupBuildDirectory() {
                if ( is_dir( $this->buildDir ) ) {
                        $this->execCmd( 'rm', '-rf', '--', $this->buildDir );

-- 
To view, visit https://gerrit.wikimedia.org/r/242332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ea749931ad266653624185583fdcd3f7473434
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>

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

Reply via email to