Skip to content

Commit b7be4fc

Browse files
authored
Rollup merge of #89929 - yuvaldolev:handle-submodule-checkout-more-gracefully, r=Mark-Simulacrum
Handling submodule update failures more gracefully from x.py Addresses #80498 Handling the case where x.py can't check out the right commit of a submodule, because the submodule has local edits that would be overwritten by the checkout, more gracefully. The error is printed in detail, with some hints on how to revert the local changes to the submodule.
2 parents c654005 + 95ae868 commit b7be4fc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bootstrap/bootstrap.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,15 @@ def update_submodule(self, module, checked_out, recorded_submodules):
10261026
if self.git_version >= distutils.version.LooseVersion("2.11.0"):
10271027
update_args.append("--progress")
10281028
update_args.append(module)
1029-
run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
1029+
try:
1030+
run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
1031+
except RuntimeError:
1032+
print("Failed updating submodule. This is probably due to uncommitted local changes.")
1033+
print('Either stash the changes by running "git stash" within the submodule\'s')
1034+
print('directory, reset them by running "git reset --hard", or commit them.')
1035+
print("To reset all submodules' changes run", end=" ")
1036+
print('"git submodule foreach --recursive git reset --hard".')
1037+
raise SystemExit(1)
10301038

10311039
run(["git", "reset", "-q", "--hard"],
10321040
cwd=module_path, verbose=self.verbose)

0 commit comments

Comments
 (0)