Commit 2250d5b3 authored by rmistry's avatar rmistry Committed by Commit bot

Add apply_gerrit_ref to bot_update api.

BUG=skia:5627

Review-Url: https://codereview.chromium.org/2249983004
parent 2cbf79f3
......@@ -53,6 +53,27 @@ class BotUpdateApi(recipe_api.RecipeApi):
def last_returned_properties(self):
return self._last_returned_properties
# DO NOT USE.
# The below method will be removed after there are no more callers of
# tryserver.maybe_apply_issue (skbug.com/5588).
def apply_gerrit_ref(self, root, gerrit_no_reset=False,
gerrit_rebase_patch_ref=True, **kwargs):
apply_gerrit_path = self.resource('apply_gerrit.py')
kwargs.setdefault('infra_step', True)
kwargs.setdefault('env', {}).setdefault('PATH', '%(PATH)s')
kwargs['env']['PATH'] = self.m.path.pathsep.join([
kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)])
cmd = [
'--gerrit_repo', self._repository,
'--gerrit_ref', self._gerrit_ref or '',
'--root', str(root),
]
if gerrit_no_reset:
cmd.append('--gerrit_no_reset')
if gerrit_rebase_patch_ref:
cmd.append('--gerrit_rebase_patch_ref')
return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs)
def ensure_checkout(self, gclient_config=None, suffix=None,
patch=True, update_presentation=True,
force=False, patch_root=None, no_shallow=False,
......
[
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[depot_tools::bot_update]/resources/apply_gerrit.py",
"--gerrit_repo",
"chromium",
"--gerrit_ref",
"",
"--root",
"/tmp/test/root",
"--gerrit_no_reset",
"--gerrit_rebase_patch_ref"
],
"env": {
"PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]"
},
"name": "apply_gerrit"
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
......@@ -35,18 +35,25 @@ def RunSteps(api):
suffix = api.properties.get('suffix')
gerrit_no_reset = True if api.properties.get('gerrit_no_reset') else False
gerrit_rebase_patch_ref = bool(api.properties.get('gerrit_rebase_patch_ref'))
api.bot_update.ensure_checkout(
force=force,
no_shallow=no_shallow,
patch=patch,
with_branch_heads=with_branch_heads,
output_manifest=output_manifest,
refs=refs, patch_oauth2=oauth2,
clobber=clobber,
root_solution_revision=root_solution_revision,
suffix=suffix,
gerrit_no_reset=gerrit_no_reset,
gerrit_rebase_patch_ref=gerrit_rebase_patch_ref)
if api.properties.get('test_apply_gerrit_ref'):
api.bot_update.apply_gerrit_ref(
root='/tmp/test/root',
gerrit_no_reset=gerrit_no_reset,
gerrit_rebase_patch_ref=gerrit_rebase_patch_ref)
else:
api.bot_update.ensure_checkout(
force=force,
no_shallow=no_shallow,
patch=patch,
with_branch_heads=with_branch_heads,
output_manifest=output_manifest,
refs=refs, patch_oauth2=oauth2,
clobber=clobber,
root_solution_revision=root_solution_revision,
suffix=suffix,
gerrit_no_reset=gerrit_no_reset,
gerrit_rebase_patch_ref=gerrit_rebase_patch_ref)
def GenTests(api):
......@@ -163,6 +170,12 @@ def GenTests(api):
slavename='somehost',
gerrit_rebase_patch_ref=True
)
yield api.test('apply_gerrit_ref') + api.properties(
repository='chromium',
gerrit_rebase_patch_ref=True,
gerrit_no_reset=1,
test_apply_gerrit_ref=True,
)
yield api.test('tryjob_v8') + api.properties(
mastername='tryserver.chromium.linux',
buildername='linux_rel',
......
#!/usr/bin/env python
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import optparse
import sys
import bot_update # pylint: disable=relative-import
if __name__ == '__main__':
parse = optparse.OptionParser()
parse.add_option('--gerrit_repo',
help='Gerrit repository to pull the ref from.')
parse.add_option('--gerrit_ref', help='Gerrit ref to apply.')
parse.add_option('--root', help='The location of the checkout.')
parse.add_option('--gerrit_no_reset', action='store_true',
help='Bypass calling reset after applying a gerrit ref.')
parse.add_option('--gerrit_rebase_patch_ref', action='store_true',
help='Rebase Gerrit patch ref after of checking it out.')
options, _ = parse.parse_args()
sys.exit(
bot_update.apply_gerrit_ref(
options.gerrit_repo,
options.gerrit_ref,
options.root,
not options.gerrit_no_reset,
options.gerrit_rebase_patch_ref)
)
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