@@ -32,14 +32,18 @@ sys.path.append(os.path.join(SCRIPT_DIR, 'swift_build_support'))
32
32
from swift_build_support import shell # noqa (E402)
33
33
34
34
35
- def update_single_repository (repo_path , branch , reset_to_remote ):
35
+ def update_single_repository (repo_path , branch , reset_to_remote , should_clean ):
36
36
if not os .path .isdir (repo_path ):
37
37
return
38
38
39
39
print ("--- Updating '" + repo_path + "' ---" )
40
40
with shell .pushd (repo_path , dry_run = False , echo = False ):
41
41
shell .call (["git" , "fetch" ], echo = False )
42
42
43
+ if should_clean :
44
+ shell .call (['git' , 'clean' , '-fdx' ],
45
+ echo = False )
46
+
43
47
if branch :
44
48
status = shell .capture (['git' , 'status' , '--porcelain' , '-uno' ],
45
49
echo = False )
@@ -83,7 +87,8 @@ def update_all_repositories(args, config, scheme_name):
83
87
84
88
update_single_repository (os .path .join (SWIFT_SOURCE_ROOT , repo_name ),
85
89
repo_branch ,
86
- args .reset_to_remote )
90
+ args .reset_to_remote ,
91
+ args .clean )
87
92
88
93
89
94
def obtain_additional_swift_sources (
@@ -194,6 +199,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
194
199
'--reset-to-remote' ,
195
200
help = 'Reset each branch to the remote state.' ,
196
201
action = 'store_true' )
202
+ parser .add_argument (
203
+ '--clean' ,
204
+ help = 'Clean unrelated files from each repository.' ,
205
+ action = 'store_true' )
197
206
parser .add_argument (
198
207
"--config" ,
199
208
default = os .path .join (SCRIPT_DIR , "update-checkout-config.json" ),
0 commit comments