diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index a751904ea..0daabdab9 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -47,14 +47,14 @@ Recipe module to ensure a checkout is consistent on a bot. Wrapper for easy calling of bot_update. -— **def [apply\_gerrit\_ref](/recipes/recipe_modules/bot_update/api.py#49)(self, root, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, \*\*kwargs):** +— **def [apply\_gerrit\_ref](/recipes/recipe_modules/bot_update/api.py#49)(self, root, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, gerrit_repo=None, gerrit_ref=None, \*\*kwargs):** -— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#427)(self, bot_update_step):** +— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#428)(self, bot_update_step):** Deapplies a patch, taking care of DEPS and solution revisions properly. -— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#69)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, no_shallow=False, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=False, oauth2_json=False, use_site_config_creds=True, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, \*\*kwargs):** +— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#70)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, no_shallow=False, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=False, oauth2_json=False, use_site_config_creds=True, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, \*\*kwargs):** Args: use_site_config_creds: If the oauth2 credentials are in the buildbot @@ -71,7 +71,7 @@ Args: Needed as migration paths for recipes dealing with older revisions, such as bisect. -— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#404)(self, project_name, gclient_config=None):** +— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#405)(self, project_name, gclient_config=None):** Returns all property names used for storing the checked-out revision of a given project. diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 883f99bab..2e9d9e629 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -47,12 +47,13 @@ class BotUpdateApi(recipe_api.RecipeApi): # DO NOT USE. # TODO(tandrii): refactor this into tryserver.maybe_apply_patch def apply_gerrit_ref(self, root, gerrit_no_reset=False, - gerrit_no_rebase_patch_ref=False, **kwargs): + gerrit_no_rebase_patch_ref=False, + gerrit_repo=None, gerrit_ref=None, **kwargs): apply_gerrit_path = self.resource('apply_gerrit.py') kwargs.setdefault('infra_step', True) cmd = [ - '--gerrit_repo', self._repository, - '--gerrit_ref', self._gerrit_ref or '', + '--gerrit_repo', gerrit_repo or self._repository, + '--gerrit_ref', gerrit_ref or self._gerrit_ref or '', '--root', str(root), ] if gerrit_no_reset: diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json b/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json new file mode 100644 index 000000000..1c948dba4 --- /dev/null +++ b/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json @@ -0,0 +1,29 @@ +[ + { + "cmd": [ + "python", + "-u", + "RECIPE_MODULE[depot_tools::bot_update]/resources/apply_gerrit.py", + "--gerrit_repo", + "https://custom/repo", + "--gerrit_ref", + "refs/changes/custom/1234567/1", + "--root", + "/tmp/test/root", + "--gerrit_no_reset", + "--gerrit_no_rebase_patch_ref" + ], + "env_prefixes": { + "PATH": [ + "RECIPE_PACKAGE_REPO[depot_tools]" + ] + }, + "infra_step": true, + "name": "apply_gerrit" + }, + { + "name": "$result", + "recipe_result": null, + "status_code": 0 + } +] \ No newline at end of file diff --git a/recipes/recipe_modules/bot_update/examples/full.py b/recipes/recipe_modules/bot_update/examples/full.py index af532528d..661bb5e2e 100644 --- a/recipes/recipe_modules/bot_update/examples/full.py +++ b/recipes/recipe_modules/bot_update/examples/full.py @@ -51,7 +51,10 @@ def RunSteps(api): api.bot_update.apply_gerrit_ref( root='/tmp/test/root', gerrit_no_reset=gerrit_no_reset, - gerrit_no_rebase_patch_ref=gerrit_no_rebase_patch_ref) + gerrit_no_rebase_patch_ref=gerrit_no_rebase_patch_ref, + gerrit_repo=api.properties.get('gerrit_custom_repo'), + gerrit_ref=api.properties.get('gerrit_custom_ref'), + ) else: bot_update_step = api.bot_update.ensure_checkout( no_shallow=no_shallow, @@ -156,6 +159,14 @@ def GenTests(api): gerrit_no_reset=1, test_apply_gerrit_ref=True, ) + yield api.test('apply_gerrit_ref_custom') + api.properties( + repository='chromium', + gerrit_no_rebase_patch_ref=True, + gerrit_no_reset=1, + gerrit_custom_repo='https://custom/repo', + gerrit_custom_ref='refs/changes/custom/1234567/1', + test_apply_gerrit_ref=True, + ) yield api.test('tryjob_v8') + api.properties( issue=12345, patchset=654321,