checkout: Add manifest_path property
Bug: b/341756093
Change-Id: I1dce690d8be8a395fcd8968fa72442ec1ddd60bd
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/229074
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Danielle Kay <danikay@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index 0aff986..2d57cf3 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -227,6 +227,10 @@
self._revision = self._api.checkout.get_revision(self.root)
return self._revision
+ @property
+ def manifest_path(self) -> config_types.Path:
+ return self.root / self.options.manifest_file
+
def applied_changes(self) -> list[Change]:
return [x for x in self.changes if x.applied]
diff --git a/recipe_modules/checkout/tests/repo.py b/recipe_modules/checkout/tests/repo.py
index 415d7f5..eaecbe7 100644
--- a/recipe_modules/checkout/tests/repo.py
+++ b/recipe_modules/checkout/tests/repo.py
@@ -34,6 +34,7 @@
def RunSteps(api, props): # pylint: disable=invalid-name
checkout = api.checkout(props.checkout_options)
+ _ = checkout.manifest_path # For coverage.
with api.step.nest('changes'):
for i, change in enumerate(checkout.changes):
diff --git a/recipes/repo_roller.py b/recipes/repo_roller.py
index d2dea13..6f14db9 100644
--- a/recipes/repo_roller.py
+++ b/recipes/repo_roller.py
@@ -75,7 +75,6 @@
props.checkout_options.use_trigger = False
checkout = api.checkout(props.checkout_options)
- filepath = checkout.root / checkout.options.manifest_file
new_revision = None
@@ -89,7 +88,7 @@
tree = _TreeBuilder()
parser = xml.etree.ElementTree.XMLParser(target=tree)
- parser.feed(api.file.read_text('read manifest', filepath))
+ parser.feed(api.file.read_text('read manifest', checkout.manifest_path))
parser.close()
root = tree.close()
@@ -216,7 +215,7 @@
api.file.write_text(
'write manifest',
- filepath,
+ checkout.manifest_path,
'<?xml version="1.0" encoding="UTF-8"?>\n{}\n'.format(
xml.etree.ElementTree.tostring(root).decode(),
),