blob: e55bfeba2915e42323296bc325f3bd81608020d5 [file] [log] [blame]
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Update submodules in a Git repository."""
from PB.recipes.fuchsia.submodule_roller import InputProperties
PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"fuchsia/auto_roller",
"fuchsia/buildbucket_util",
"fuchsia/gerrit",
"fuchsia/git",
"fuchsia/git_checkout",
"recipe_engine/context",
"recipe_engine/path",
"recipe_engine/properties",
]
PROPERTIES = InputProperties
def RunSteps(api, props):
# Note that we only support Git checkouts. Jiri checkouts are not expected
# to have submodules.
checkout_dir = api.path.mkdtemp("checkout")
api.git_checkout(props.remote, path=checkout_dir)
with api.context(cwd=checkout_dir):
api.git.update_submodule(
paths=props.submodule_paths,
init=False,
remote=True,
)
change = api.auto_roller.attempt_roll(
api.gerrit.host_from_remote_url(props.remote),
gerrit_project=api.gerrit.project_from_remote_url(props.remote),
repo_dir=checkout_dir,
# TODO(atyfto): Improve the commit message.
commit_message="[roll] Update submodules",
commit_untracked=True,
cl_notify_option=props.cl_notify_option,
create_unique_id=props.create_unique_change_id,
dry_run=props.dry_run,
)
return api.auto_roller.raw_result(change)
def GenTests(api):
default_props = api.properties(
submodule_paths=["a", "b", "c/d", "e"],
remote="https://fuchsia.googlesource.com/integration",
)
yield api.buildbucket_util.test(
"roll", builder="submodule-roller"
) + api.auto_roller.success() + default_props