Skip to content

Commit 74b9206

Browse files
committed
[update-checkout] Refactor out the update working copy loop into its own function (update_all_repositories) and rename the old update_working_copy to update_single_repository (which is really what it does).
1 parent ceb71b5 commit 74b9206

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

utils/update-checkout

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sys.path.append(os.path.join(SCRIPT_DIR, 'swift_build_support'))
3232
from swift_build_support import shell # noqa (E402)
3333

3434

35-
def update_working_copy(repo_path, branch):
35+
def update_single_repository(repo_path, branch):
3636
if not os.path.isdir(repo_path):
3737
return
3838

@@ -56,6 +56,23 @@ def update_working_copy(repo_path, branch):
5656
echo=False)
5757

5858

59+
def update_all_repositories(args, config, branch):
60+
repo_branch = branch
61+
for dir_name in config["repositories"].keys():
62+
if dir_name in args.skip_repository:
63+
print("--- Skipping '" + dir_name + "' ---")
64+
continue
65+
if branch:
66+
for config_branch_name in config['branch-names']:
67+
if branch not in config[config_branch_name]['aliases']:
68+
continue
69+
repo_branch = config[config_branch_name]['repos'][dir_name]
70+
break
71+
72+
update_single_repository(os.path.join(SWIFT_SOURCE_ROOT, dir_name),
73+
repo_branch)
74+
75+
5976
def obtain_additional_swift_sources(
6077
config, with_ssh, branch, skip_history, skip_repositories):
6178
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False,
@@ -173,23 +190,9 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
173190
obtain_additional_swift_sources(
174191
config, clone_with_ssh, branch, skip_history, args.skip_repository)
175192

176-
repo_branch = branch
177-
for dir_name in config["repositories"].keys():
178-
if dir_name in args.skip_repository:
179-
print("--- Skipping '" + dir_name + "' ---")
180-
continue
181-
if branch:
182-
for config_branch_name in config['branch-names']:
183-
if branch not in config[config_branch_name]['aliases']:
184-
continue
185-
repo_branch = config[config_branch_name]['repos'][dir_name]
186-
break
187-
188-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, dir_name),
189-
repo_branch)
193+
update_all_repositories(args, config, branch)
190194

191195
return 0
192196

193-
194197
if __name__ == "__main__":
195198
sys.exit(main())

0 commit comments

Comments
 (0)