[MediaWiki-commits] [Gerrit] mediawiki...release[master]: branch.py: Simplify

2018-01-09 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/403162 )

Change subject: branch.py: Simplify
..


branch.py: Simplify

Also start work on the "add submodules and futz with DefaultSettings"
bit

See where I'm going here?

Change-Id: Ia1268e14f30b85b73a99dbe69b3a17c93ee07229
---
M make-release/branch.py
1 file changed, 45 insertions(+), 21 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/make-release/branch.py b/make-release/branch.py
index 6e2bf3e..b895ab9 100755
--- a/make-release/branch.py
+++ b/make-release/branch.py
@@ -1,10 +1,13 @@
-#!/usr/bin/env python3
+#!/usr/bin/python3
 # vim:sw=4:ts=4:et:
 """Stuff about making branches and so forth."""
 
 import argparse
 import logging
+import os
+import subprocess
 import sys
+import tempfile
 
 from requests.auth import HTTPDigestAuth
 from requests.exceptions import HTTPError
@@ -32,6 +35,7 @@
 except KeyError:
 pass
 
+print('Branching {} to {} from {}'.format(repository, branch, 
revision))
 _get_client().put(
 '/projects/%s/branches/%s' % (
 repository.replace('/', '%2F'),
@@ -41,30 +45,42 @@
 except HTTPError as httpe:
 # Gerrit responds 409 for edit conflicts
 # means we already have a branch
-if httpe.response.status_code != 409:
+if httpe.response.status_code == 409:
+print('Already branched!')
+else:
 raise
 
 
-def branch_everything(branch, branch_point, bundle=None):
-"""Branch stuff."""
+def get_bundle(bundle):
+"""Return the list of all/some extensions, skins, and vendor."""
 if bundle == '*':
-repos_to_branch = get_star_bundle()
-
-for repo in repos_to_branch:
-print('Branching %s to %s from %s' % (
-repo, branch, branch_point))
-create_branch(repo, branch, branch_point)
+things_to_branch = []
+for stuff in ['skins', 'extensions']:
+projects = _get_client().get('/projects/?p=mediawiki/%s' % stuff)
+for proj in projects:
+if projects[proj]['state'] == 'ACTIVE':
+things_to_branch.append(proj)
+return things_to_branch
+else:
+try:
+return CONFIG['bundles'][bundle]
+except KeyError:
+return []
 
 
-def get_star_bundle():
-"""Return the list of all extensions, skins, and vendor."""
-things_to_branch = []
-for stuff in ['skins', 'extensions']:
-projects = _get_client().get('/projects/?p=mediawiki/%s' % stuff)
-for proj in projects:
-if projects[proj]['state'] == 'ACTIVE':
-things_to_branch.append(proj)
-return things_to_branch
+def do_core_work(branch, bundle, version):
+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)
+for submodule in bundle:
+url = CONFIG['clone_base'] + '/' + submodule
+subprocess.check_call(['/usr/bin/git', 'submodule', 'add',
+   '--force', '--branch', branch, url,
+   submodule])
+
+os.chdir(cwd)
 
 
 def parse_args():
@@ -82,6 +98,10 @@
 help='If we branch core or not')
 parser.add_argument('--bundle', dest='bundle', default=None,
 help='What bundle of extensions & skins to branch')
+parser.add_argument(
+'--core-version',
+dest='core_version',
+help='If set, core will be given submodules with the bundle, plus this 
version number')
 
 return parser.parse_args()
 
@@ -90,7 +110,11 @@
 OPTIONS = parse_args()
 logging.basicConfig(level=logging.INFO, stream=sys.stderr)
 
+if OPTIONS.bundle:
+for repo in get_bundle(OPTIONS.bundle):
+create_branch(repo, OPTIONS.branch, OPTIONS.branch_point)
+
 if OPTIONS.core:
 create_branch('core', OPTIONS.branch, OPTIONS.branch_point)
-if OPTIONS.bundle:
-branch_everything(OPTIONS.branch, OPTIONS.branch_point, OPTIONS.bundle)
+if OPTIONS.core_version:
+do_core_work(OPTIONS.branch, OPTIONS.bundle, OPTIONS.core_version)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1268e14f30b85b73a99dbe69b3a17c93ee07229
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: Chad 
Gerrit-Reviewer: Chad 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listi

[MediaWiki-commits] [Gerrit] mediawiki...release[master]: branch.py: Simplify

2018-01-09 Thread Chad (Code Review)
Chad has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403162 )

Change subject: branch.py: Simplify
..

branch.py: Simplify

Also start work on the "add submodules and futz with DefaultSettings"
bit

See where I'm going here?

Change-Id: Ia1268e14f30b85b73a99dbe69b3a17c93ee07229
---
M make-release/branch.py
1 file changed, 45 insertions(+), 21 deletions(-)


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

diff --git a/make-release/branch.py b/make-release/branch.py
index 6e2bf3e..b895ab9 100755
--- a/make-release/branch.py
+++ b/make-release/branch.py
@@ -1,10 +1,13 @@
-#!/usr/bin/env python3
+#!/usr/bin/python3
 # vim:sw=4:ts=4:et:
 """Stuff about making branches and so forth."""
 
 import argparse
 import logging
+import os
+import subprocess
 import sys
+import tempfile
 
 from requests.auth import HTTPDigestAuth
 from requests.exceptions import HTTPError
@@ -32,6 +35,7 @@
 except KeyError:
 pass
 
+print('Branching {} to {} from {}'.format(repository, branch, 
revision))
 _get_client().put(
 '/projects/%s/branches/%s' % (
 repository.replace('/', '%2F'),
@@ -41,30 +45,42 @@
 except HTTPError as httpe:
 # Gerrit responds 409 for edit conflicts
 # means we already have a branch
-if httpe.response.status_code != 409:
+if httpe.response.status_code == 409:
+print('Already branched!')
+else:
 raise
 
 
-def branch_everything(branch, branch_point, bundle=None):
-"""Branch stuff."""
+def get_bundle(bundle):
+"""Return the list of all/some extensions, skins, and vendor."""
 if bundle == '*':
-repos_to_branch = get_star_bundle()
-
-for repo in repos_to_branch:
-print('Branching %s to %s from %s' % (
-repo, branch, branch_point))
-create_branch(repo, branch, branch_point)
+things_to_branch = []
+for stuff in ['skins', 'extensions']:
+projects = _get_client().get('/projects/?p=mediawiki/%s' % stuff)
+for proj in projects:
+if projects[proj]['state'] == 'ACTIVE':
+things_to_branch.append(proj)
+return things_to_branch
+else:
+try:
+return CONFIG['bundles'][bundle]
+except KeyError:
+return []
 
 
-def get_star_bundle():
-"""Return the list of all extensions, skins, and vendor."""
-things_to_branch = []
-for stuff in ['skins', 'extensions']:
-projects = _get_client().get('/projects/?p=mediawiki/%s' % stuff)
-for proj in projects:
-if projects[proj]['state'] == 'ACTIVE':
-things_to_branch.append(proj)
-return things_to_branch
+def do_core_work(branch, bundle, version):
+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)
+for submodule in bundle:
+url = CONFIG['clone_base'] + '/' + submodule
+subprocess.check_call(['/usr/bin/git', 'submodule', 'add',
+   '--force', '--branch', branch, url,
+   submodule])
+
+os.chdir(cwd)
 
 
 def parse_args():
@@ -82,6 +98,10 @@
 help='If we branch core or not')
 parser.add_argument('--bundle', dest='bundle', default=None,
 help='What bundle of extensions & skins to branch')
+parser.add_argument(
+'--core-version',
+dest='core_version',
+help='If set, core will be given submodules with the bundle, plus this 
version number')
 
 return parser.parse_args()
 
@@ -90,7 +110,11 @@
 OPTIONS = parse_args()
 logging.basicConfig(level=logging.INFO, stream=sys.stderr)
 
+if OPTIONS.bundle:
+for repo in get_bundle(OPTIONS.bundle):
+create_branch(repo, OPTIONS.branch, OPTIONS.branch_point)
+
 if OPTIONS.core:
 create_branch('core', OPTIONS.branch, OPTIONS.branch_point)
-if OPTIONS.bundle:
-branch_everything(OPTIONS.branch, OPTIONS.branch_point, OPTIONS.bundle)
+if OPTIONS.core_version:
+do_core_work(OPTIONS.branch, OPTIONS.bundle, OPTIONS.core_version)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1268e14f30b85b73a99dbe69b3a17c93ee07229
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: Chad 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits