Skip to content

Commit b120535

Browse files
albluejrose-apple
authored andcommitted
[build-script] Clean submodules where applicable (#4553)
When building Swift from a non-clean checkout, the `git reset` that occurs on subprojects that include submodules may fail if the submodule is deemed to have been changed (for example, by running the autoconf scripts). When cleaning the projects, ensure that `git submodule` is used to clean submodules and reset them to their original state as well, so that the project can be reset successfully. Issue: SR-2524
1 parent 1a88c86 commit b120535

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

utils/update-checkout

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ def update_single_repository(repo_path, branch, reset_to_remote, should_clean):
4343
if should_clean:
4444
shell.call(['git', 'clean', '-fdx'],
4545
echo=True)
46-
shell.call(['git', 'reset', '--hard', 'HEAD'],
46+
shell.call(['git', 'submodule', 'foreach', '--recursive', 'git', 'clean', '-fdx'],
4747
echo=True)
48+
shell.call(['git', 'submodule', 'foreach', '--recursive', 'git', 'reset', '--hard', 'HEAD'],
49+
echo=True)
50+
status = shell.call(['git', 'reset', '--hard', 'HEAD'],
51+
echo=True)
52+
if status:
53+
print("Please, commit your changes.")
54+
print(status)
55+
exit(1)
4856

4957
if branch:
5058
status = shell.capture(['git', 'status', '--porcelain', '-uno'],

0 commit comments

Comments
 (0)