aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-07-14 14:47:40 -0700
committerJoel Galenson <jgalenson@google.com>2021-07-15 07:49:10 -0700
commit58f0ddf4277bee982a83022d85b443114e439083 (patch)
tree0ff6b5ab51ad44fe1fe7865217e6e0f5f419b005
parent483f97120497905df44b406939864b18aafd3d69 (diff)
downloadexternal_updater-58f0ddf4277bee982a83022d85b443114e439083.tar.gz
Delete .gitmodules files on update.
This modifies the updater to delete all .gitmodules files. Fixes: 193552791 Test: Call on crates with and without .gitmodules changes. Change-Id: I00c096245dfddfb5d613c33e5479908586b3212c
-rw-r--r--external_updater.py1
-rw-r--r--git_utils.py5
2 files changed, 6 insertions, 0 deletions
diff --git a/external_updater.py b/external_updater.py
index 3b56e30..b4091c4 100644
--- a/external_updater.py
+++ b/external_updater.py
@@ -114,6 +114,7 @@ def _do_update(args: argparse.Namespace, updater: Updater,
rel_proj_path = fileutils.get_relative_project_path(full_path)
msg = 'Upgrade {} to {}\n\nTest: make\n'.format(
rel_proj_path, updater.latest_version)
+ git_utils.remove_gitmodules(full_path)
git_utils.add_file(full_path, '*')
git_utils.commit(full_path, msg)
except Exception as err:
diff --git a/git_utils.py b/git_utils.py
index e369af3..5186eb3 100644
--- a/git_utils.py
+++ b/git_utils.py
@@ -154,6 +154,11 @@ def add_file(proj_path: Path, file_name: str) -> None:
_run(['git', 'add', file_name], cwd=proj_path)
+def remove_gitmodules(proj_path: Path) -> None:
+ """Deletes .gitmodules files."""
+ _run(['find', '.', '-name', '.gitmodules', '-delete'], cwd=proj_path)
+
+
def delete_branch(proj_path: Path, branch_name: str) -> None:
"""Force delete a branch."""
_run(['git', 'branch', '-D', branch_name], cwd=proj_path)