Skip to content

Commit

Permalink
Rollup merge of #89929 - yuvaldolev:handle-submodule-checkout-more-gr…
Browse files Browse the repository at this point in the history
…acefully, 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.
  • Loading branch information
matthiaskrgr authored Nov 1, 2021
2 parents c654005 + 95ae868 commit b7be4fc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,15 @@ def update_submodule(self, module, checked_out, recorded_submodules):
if self.git_version >= distutils.version.LooseVersion("2.11.0"):
update_args.append("--progress")
update_args.append(module)
run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
try:
run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
except RuntimeError:
print("Failed updating submodule. This is probably due to uncommitted local changes.")
print('Either stash the changes by running "git stash" within the submodule\'s')
print('directory, reset them by running "git reset --hard", or commit them.')
print("To reset all submodules' changes run", end=" ")
print('"git submodule foreach --recursive git reset --hard".')
raise SystemExit(1)

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

0 comments on commit b7be4fc

Please sign in to comment.