| # 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 |
| |
| DEPS = [ |
| "fuchsia/auto_roller", |
| "fuchsia/buildbucket_util", |
| "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( |
| props.roll_options, |
| repo_dir=checkout_dir, |
| # TODO(atyfto): Improve the commit message. |
| commit_message="[roll] Update submodules", |
| ) |
| return api.auto_roller.raw_result(change) |
| |
| |
| def GenTests(api): |
| default_props = api.properties( |
| InputProperties( |
| submodule_paths=["a", "b", "c/d", "e"], |
| remote="https://fuchsia.googlesource.com/integration", |
| roll_options=api.auto_roller.Options( |
| remote="https://fuchsia.googlesource.com/integration", |
| ), |
| ), |
| ) |
| |
| yield api.buildbucket_util.test( |
| "roll", builder="submodule-roller" |
| ) + api.auto_roller.success() + default_props |