Don't stage removals in git when --skip-cls is used.
--skip-cls is supposed to leave out git, including the staging index.
Test: art/build/update-art-module-prebuilts.py \
--skip-cls --local-dist=...
Bug: 172480615
Change-Id: I58ad4ac573241b1c83400258932f1de8a0ba0cea
diff --git a/build/update-art-module-prebuilts.py b/build/update-art-module-prebuilts.py
index 3a41c77..8d41d47 100755
--- a/build/update-art-module-prebuilts.py
+++ b/build/update-art-module-prebuilts.py
@@ -193,11 +193,12 @@
check_call(["repo", "upload", "-t", "--br=" + branch_name, git_root])
-def remove_files(git_root, subpaths):
- """Removes files in the work tree, and stages the removals in git."""
- check_call(["git", "rm", "-qrf", "--ignore-unmatch"] + subpaths, cwd=git_root)
- # Need a plain rm afterwards because git won't remove directories if they have
- # non-git files in them.
+def remove_files(git_root, subpaths, stage_removals):
+ """Removes files in the work tree, optionally staging them in git."""
+ if stage_removals:
+ check_call(["git", "rm", "-qrf", "--ignore-unmatch"] + subpaths, cwd=git_root)
+ # Need a plain rm afterwards even if git rm was executed, because git won't
+ # remove directories if they have non-git files in them.
check_call(["rm", "-rf"] + subpaths, cwd=git_root)
@@ -318,7 +319,7 @@
start_branch(branch_name, install_paths_per_root.keys())
for git_root, subpaths in install_paths_per_root.items():
- remove_files(git_root, subpaths)
+ remove_files(git_root, subpaths, not args.skip_cls)
for entry in install_entries:
install_entry(args.build, args.local_dist, entry)