Chad has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403219 )

Change subject: branch.py: Cleanup/prep for sub-submodule support
......................................................................

branch.py: Cleanup/prep for sub-submodule support

Change-Id: Ib75335404a5a2d66aaf7112738ac1a9c38fa5413
---
M make-release/branch.py
M make-release/make-release.yaml
2 files changed, 33 insertions(+), 16 deletions(-)


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

diff --git a/make-release/branch.py b/make-release/branch.py
index 3a6e9b9..8aff26f 100755
--- a/make-release/branch.py
+++ b/make-release/branch.py
@@ -3,8 +3,10 @@
 """Stuff about making branches and so forth."""
 
 import argparse
+from contextlib import contextmanager
 import logging
 import os
+import shutil
 import subprocess
 import sys
 import tempfile
@@ -27,13 +29,26 @@
         auth=HTTPDigestAuth(CONFIG['username'], CONFIG['password']))
 
 
+def get_branchpoint(branch, repository, default):
+    try:
+        return CONFIG['manual_branch_points'][branch][repository]
+    except KeyError:
+        return default
+
+
 def create_branch(repository, branch, revision):
     """Create a branch for a given repo."""
+    # If we've got a sub-submodule we care about, branch it first so we can
+    # do some magic stuff
     try:
-        try:
-            revision = CONFIG['manual_branch_points'][branch][repository]
-        except KeyError:
-            pass
+        subrepo = CONFIG['sub_submodules'][repository]
+        create_branch(subrepo, branch, revision)
+    except KeyError:
+        # This is the normal case, actually
+        pass
+
+    try:
+        revision = get_branchpoint(branch, repository, revision)
 
         print('Branching {} to {} from {}'.format(repository, branch, 
revision))
         _get_client().put(
@@ -49,13 +64,6 @@
             print('Already branched!')
         else:
             raise
-
-    # If we've got a sub-submodule we care about, branch it too
-    try:
-        subrepo = CONFIG['sub_submodules'][repo]
-        create_branch(subrepo, branch, revision)
-    except KeyError:
-        pass
 
 
 def get_bundle(bundle):
@@ -75,13 +83,22 @@
             return []
 
 
+@contextmanager
+def clone(repository):
+    url = CONFIG['clone_base'] + '/' + repository
+    temp = tempfile.mkdtemp()
+    subprocess.check_call(['/usr/bin/git', 'clone', url, temp])
+    cwd = os.getcwd()
+    os.chdir(temp)
+    yield temp
+    os.chdir(cwd)
+    shutil.rmtree(temp)
+
+
 def do_core_work(branch, bundle, version):
     """Add submodules, bump $wgVersion, etc"""
     cwd = os.getcwd()
-    with tempfile.TemporaryDirectory() as temp:
-        subprocess.check_call(['/usr/bin/git', 'clone', '-b', branch,
-                               CONFIG['clone_base'] + '/core', temp])
-        os.chdir(temp)
+    with clone('core'):
         for submodule in bundle:
             url = CONFIG['clone_base'] + '/' + submodule
             subprocess.check_call(['/usr/bin/git', 'submodule', 'add',
diff --git a/make-release/make-release.yaml b/make-release/make-release.yaml
index c5a2551..8af0605 100644
--- a/make-release/make-release.yaml
+++ b/make-release/make-release.yaml
@@ -31,7 +31,7 @@
     REL1_30:
         core: 0cd28e19cb0f9385a2a1cc11a4d8c9c21ff0b830
 sub_submodules:
-    - extensions/VisualEditor: lib/ve
+    extensions/VisualEditor: lib/ve
 diff:
     ignore:
         - "*~"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib75335404a5a2d66aaf7112738ac1a9c38fa5413
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