Thcipriani has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258203
Change subject: Add flag to resume branching from named extension
......................................................................
Add flag to resume branching from named extension
Adds the [-c|--continue-from] optional flag to `make-wmf-branch`. Setting
this flag to the name of an extension in the `config.json` file will
resume cutting new branches on branched extensions from that extension
forward.
Currently, if branching of extensions fails on a particular extension
the workflow is:
0. Figure out why branching that extension failed, fix it.
1. Delete the extension names from `make-wmf-branch/config.json`
that occur before the extension that failed.
2. Re-run `make-wmf-branch/make-wmf-branch`.
3. Checkout the new branch of mediawiki-core.
4. Add submodules for all the extensions you deleted from the config in
step 1.
5. Add a new patch for the new branch of core in gerrit, +2, and merge.
New workflow would be:
0. Figure out why branching that extension failed, fix it.
1. Run `make-wmf-branch/make-wmf-branch -n <new> -o <old> -c
<failed-extension>`.
Change-Id: Icf1f2f9a98dcd390d8a187ce11ebe6b3e2219204
---
M make-wmf-branch/MakeWmfBranch.php
M make-wmf-branch/make-wmf-branch
2 files changed, 67 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/release
refs/changes/03/258203/1
diff --git a/make-wmf-branch/MakeWmfBranch.php
b/make-wmf-branch/MakeWmfBranch.php
index 8da0714..24569ac 100644
--- a/make-wmf-branch/MakeWmfBranch.php
+++ b/make-wmf-branch/MakeWmfBranch.php
@@ -31,11 +31,53 @@
$this->branchedSubmodules = $branchLists['submodules'];
$this->branchedSkins = $branchLists['skins'];
$this->specialExtensions = $branchLists['special_extensions'];
+ $this->alreadyBranched = array();
$this->noisy = $noisy;
$this->patches = $patches;
$this->baseRepoPath = $baseRepoPath;
$this->anonRepoPath = $anonRepoPath;
$this->branchPrefix = $branchPrefix;
+ }
+
+ /**
+ * setup an alreadyBranched array that has the names of all extensions
+ * up-to the extension from which we would like to start branching
+ *
+ * @param String/null $extName - name of extension from which to start
branching
+ */
+ function setStartExtension( $extName ) {
+ if ( $extName === null )
+ return;
+
+ $foundKey = false;
+ foreach ( array(
+ $this->branchedExtensions,
+ $this->branchedSkins,
+ array( 'vendor' ),
+ ) as $branchedArr ) {
+ $key = array_search( $extName, $branchedArr);
+
+ if ( $key !== false ) {
+ array_splice( $branchedArr, $key );
+ $foundKey = true;
+ }
+
+ $this->alreadyBranched = array_merge(
+ $this->alreadyBranched,
+ $branchedArr
+ );
+
+ if ( $foundKey )
+ break;
+ }
+
+ if ( !$foundKey )
+ $this->croak(
+ "Could not find extension '{$extName}' in any
branched Extension list"
+ );
+
+ // Should make searching array easier
+ $this->alreadyBranched = array_flip( $this->alreadyBranched );
}
function runCmd( /*...*/ ) {
@@ -80,7 +122,10 @@
}
function croak( $msg ) {
- fwrite( STDERR, "$msg\n" );
+ $red = `tput setaf 1`;
+ $reset = `tput sgr0`;
+
+ fprintf( STDERR, "[{$red}ERROR{$reset}] %s\n", $msg );
exit( 1 );
}
@@ -125,6 +170,11 @@
function branchRepo( $path ) {
$repo = basename( $path );
+
+ // repo has already been branched, so just bail out
+ if ( isset( $this->alreadyBranched[$repo] ) )
+ return;
+
$this->runCmd( 'git', 'clone', '-q',
"{$this->baseRepoPath}/{$path}.git", $repo );
$this->chdir( $repo );
$newVersion = $this->branchPrefix . $this->newVersion;
diff --git a/make-wmf-branch/make-wmf-branch b/make-wmf-branch/make-wmf-branch
index 3e613ca..ae329b0 100755
--- a/make-wmf-branch/make-wmf-branch
+++ b/make-wmf-branch/make-wmf-branch
@@ -4,6 +4,7 @@
const USAGE = <<<EOF
make-wmf-branch -n <new-branch> -o <old-branch> [-p wmf-clone-path]
+ [-c extension-name]
Example: make-wmf-branch -o 1.27.0-wmf.8 -n 1.27.0-wmf.9
@@ -13,14 +14,24 @@
-o, --old Old branch
-p, --path Path on local disk from which to
branch mediawiki-core
+ -c, --continue-from Extension from which to resume
+ branching. Mainly useful in the case
+ where initial branching fails.
+
+ Example `--continue-from` Usage:
+ --------------------------------
+ Branching fails on the `AccountAudit` extension. Use `-c AccountAudit` to
+ skip branching any previously successfully branched extensions and start
+ with branching `AccountAudit`.
EOF;
-$passedArgs = getopt( 'hn:o:p:', array(
+$passedArgs = getopt( 'hn:o:p:c:', array(
'help',
'new:',
'old:',
'path:',
+ 'continue-from:',
) );
if ( isset( $passedArgs['help'] ) || isset( $passedArgs['h'] ) ) {
@@ -32,6 +43,7 @@
array( 'n', 'new', 'newVersion', true ),
array( 'o', 'old', 'oldVersion', true ),
array( 'p', 'path', 'clonePath', false ),
+ array( 'c', 'continue-from', 'firstExtension', false ),
);
foreach ( $storedArgs as $args ) {
@@ -81,8 +93,8 @@
exit(1);
}
-$changes = trim('git status --porcelain');
-if (!empty($changes)) {
+$changes = `git status --porcelain`;
+if ( !empty( $changes ) ) {
echo "Warning: You have local changes in your tools/release checkout:\n";
echo $changes."\n\n";
}
@@ -90,4 +102,5 @@
require_once( __DIR__ . '/MakeWmfBranch.php' );
$obj = new MakeWmfBranch( $newVersion, $oldVersion );
+$obj->setStartExtension( $firstExtension );
$obj->execute( $clonePath );
--
To view, visit https://gerrit.wikimedia.org/r/258203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf1f2f9a98dcd390d8a187ce11ebe6b3e2219204
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: Thcipriani <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits