Commit 1ae7d33b authored by recipe-roller's avatar recipe-roller Committed by Commit Bot

Roll recipe dependencies (trivial).

This is an automated CL created by the recipe roller. This CL rolls recipe
changes from upstream projects (e.g. depot_tools) into downstream projects
(e.g. tools/build).


More info is at https://goo.gl/zkKdpD. Use https://goo.gl/noib3a to file a bug.
recipe_engine:
  https://crrev.com/e90c11af854574dd68edd0e7c7a5e04ceb49ffd0 [recipes.cfg] remove support for api_version 1. (iannucci@chromium.org)


TBR=iannucci@chromium.org

Recipe-Tryjob-Bypass-Reason: Autoroller
Bugdroid-Send-Email: False
Change-Id: I4037656dd987d0f8aca762761e0ff8ae9034f19f
Reviewed-on: https://chromium-review.googlesource.com/499987
Reviewed-by: <recipe-roller@chromium.org>
Commit-Queue: <recipe-roller@chromium.org>
parent 80b30caf
......@@ -15,7 +15,7 @@
"deps": {
"recipe_engine": {
"branch": "master",
"revision": "cfeeb53051e02856a35395a69b09f822ad35e2e5",
"revision": "e90c11af854574dd68edd0e7c7a5e04ceb49ffd0",
"url": "https://chromium.googlesource.com/external/github.com/luci/recipes-py.git"
}
},
......
......@@ -51,9 +51,15 @@ from cStringIO import StringIO
EngineDep = namedtuple('EngineDep',
'url revision path_override branch repo_type')
class MalformedRecipesCfg(Exception):
def __init__(self, msg, path):
super(MalformedRecipesCfg, self).__init__('malformed recipes.cfg: %s: %r'
% (msg, path))
def parse(repo_root, recipes_cfg_path):
"""Parse is transitional code which parses a recipes.cfg file as either jsonpb
or as textpb.
"""Parse is a lightweight a recipes.cfg file parser.
Args:
repo_root (str) - native path to the root of the repo we're trying to run
......@@ -69,40 +75,38 @@ def parse(repo_root, recipes_cfg_path):
with open(recipes_cfg_path, 'rU') as fh:
pb = json.load(fh)
if pb['api_version'] == 1:
# TODO(iannucci): remove when we only support version 2
engine = next(
(d for d in pb['deps'] if d['project_id'] == 'recipe_engine'), None)
if engine is None:
raise ValueError('could not find recipe_engine dep in %r'
% recipes_cfg_path)
else:
try:
if pb['api_version'] != 2:
raise MalformedRecipesCfg('unknown version %d' % pb['api_version'],
recipes_cfg_path)
engine = pb['deps']['recipe_engine']
if 'url' not in engine:
raise ValueError(
'Required field "url" in dependency "recipe_engine" not found: %r' %
(recipes_cfg_path,)
)
engine.setdefault('revision', '')
engine.setdefault('path_override', '')
engine.setdefault('branch', 'refs/heads/master')
recipes_path = pb.get('recipes_path', '')
# TODO(iannucci): only support absolute refs
if not engine['branch'].startswith('refs/'):
engine['branch'] = 'refs/heads/' + engine['branch']
engine.setdefault('repo_type', 'GIT')
if engine['repo_type'] not in ('GIT', 'GITILES'):
raise ValueError(
'Unsupported "repo_type" value in dependency "recipe_engine": %r' %
(recipes_cfg_path,)
)
recipes_path = os.path.join(repo_root, recipes_path.replace('/', os.path.sep))
return EngineDep(**engine), recipes_path
if 'url' not in engine:
raise MalformedRecipesCfg(
'Required field "url" in dependency "recipe_engine" not found',
recipes_cfg_path)
engine.setdefault('revision', '')
engine.setdefault('path_override', '')
engine.setdefault('branch', 'refs/heads/master')
recipes_path = pb.get('recipes_path', '')
# TODO(iannucci): only support absolute refs
if not engine['branch'].startswith('refs/'):
engine['branch'] = 'refs/heads/' + engine['branch']
engine.setdefault('repo_type', 'GIT')
if engine['repo_type'] not in ('GIT', 'GITILES'):
raise MalformedRecipesCfg(
'Unsupported "repo_type" value in dependency "recipe_engine"',
recipes_cfg_path)
recipes_path = os.path.join(
repo_root, recipes_path.replace('/', os.path.sep))
return EngineDep(**engine), recipes_path
except KeyError as ex:
raise MalformedRecipesCfg(ex.message, recipes_cfg_path)
GIT = 'git.bat' if sys.platform.startswith(('win', 'cygwin')) else 'git'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment