Skip to content

Commit e3de850

Browse files
committed
[update-checkout] Small refactoring to make it clear that config['repos'] contains generic repo information, not just remote information.
I was trying to get this right a bit ago, but I remained unhappy with the result. This at least makes it clear when reading the config file that config['repos'].keys() serves in the code as the "source" of the names of repositories.
1 parent aec15fa commit e3de850

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

utils/update-checkout

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def update_single_repository(repo_path, branch):
5858

5959
def update_all_repositories(args, config, scheme_name):
6060
repo_branch = scheme_name
61-
for repo_name in config["repositories"].keys():
61+
for repo_name in config['repos'].keys():
6262
if repo_name in args.skip_repository:
6363
print("--- Skipping '" + repo_name + "' ---")
6464
continue
@@ -81,45 +81,46 @@ def obtain_additional_swift_sources(
8181
config, with_ssh, scheme_name, skip_history, skip_repositories):
8282
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False,
8383
echo=False):
84-
for dir_name, repo_info in config['repositories'].items():
85-
if dir_name in skip_repositories:
86-
print("--- Skipping '" + dir_name + "' ---")
84+
for repo_name, repo_info in config['repos'].items():
85+
if repo_name in skip_repositories:
86+
print("--- Skipping '" + repo_name + "' ---")
8787
continue
8888

89-
if os.path.isdir(os.path.join(dir_name, ".git")):
89+
if os.path.isdir(os.path.join(repo_name, ".git")):
9090
continue
9191

92-
print("--- Cloning '" + dir_name + "' ---")
92+
print("--- Cloning '" + repo_name + "' ---")
9393

9494
# If we have a url override, use that url instead of
9595
# interpolating.
96-
if 'url' in repo_info:
97-
remote = repo_info['url']
96+
remote_repo_info = repo_info['remote']
97+
if 'url' in remote_repo_info:
98+
remote = remote_repo_info['url']
9899
else:
99-
remote_repo_name = repo_info['remote-repo-name']
100+
remote_repo_id = remote_repo_info['id']
100101
if with_ssh is True or 'https-clone-pattern' not in config:
101-
remote = config['ssh-clone-pattern'] % remote_repo_name
102+
remote = config['ssh-clone-pattern'] % remote_repo_id
102103
else:
103-
remote = config['https-clone-pattern'] % remote_repo_name
104+
remote = config['https-clone-pattern'] % remote_repo_id
104105

105106
if skip_history:
106107
shell.call(['git', 'clone', '--recursive', '--depth', '1',
107-
remote, dir_name], echo=False)
108+
remote, repo_name], echo=False)
108109
else:
109110
shell.call(['git', 'clone', '--recursive', remote,
110-
dir_name], echo=False)
111+
repo_name], echo=False)
111112
if scheme_name:
112113
for v in config['branch-schemes'].values():
113114
if scheme_name not in v['aliases']:
114115
continue
115-
repo_branch = v['repos'][dir_name]
116+
repo_branch = v['repos'][repo_name]
116117
break
117118
else:
118119
repo_branch = scheme_name
119-
src_path = os.path.join(SWIFT_SOURCE_ROOT, dir_name,
120+
src_path = os.path.join(SWIFT_SOURCE_ROOT, repo_name,
120121
".git")
121122
shell.call(['git', '--git-dir', src_path, '--work-tree',
122-
os.path.join(SWIFT_SOURCE_ROOT, dir_name),
123+
os.path.join(SWIFT_SOURCE_ROOT, repo_name),
123124
'checkout', repo_branch], echo=False)
124125

125126

utils/update-checkout-config.json

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
{
22
"ssh-clone-pattern": "[email protected]:%s.git",
33
"https-clone-pattern": "https://github.com/%s.git",
4-
"repositories" : {
5-
"llvm": { "remote-repo-name": "apple/swift-llvm" },
6-
"clang": { "remote-repo-name": "apple/swift-clang" },
7-
"swift": { "remote-repo-name": "apple/swift-swift" },
8-
"lldb": { "remote-repo-name": "apple/swift-lldb" },
9-
"cmark": { "remote-repo-name": "apple/swift-cmark" },
10-
"llbuild": { "remote-repo-name": "apple/swift-llbuild" },
11-
"swiftpm": { "remote-repo-name": "apple/swift-package-manager" },
12-
"compiler-rt": { "remote-repo-name": "apple/swift-compiler-rt" },
13-
"swift-corelibs-xctest": { "remote-repo-name": "apple/swift-corelibs-xctest" },
14-
"swift-corelibs-foundation": { "remote-repo-name": "apple/swift-corelibs-foundation" },
15-
"swift-corelibs-libdispatch": { "remote-repo-name": "apple/swift-corelibs-libdispatch" },
16-
"swift-integration-tests": { "remote-repo-name": "apple/swift-integration-tests" }
4+
"repos" : {
5+
"llvm": {
6+
"remote": { "id": "apple/swift-llvm" } },
7+
"clang": {
8+
"remote": { "id": "apple/swift-clang" } },
9+
"swift": {
10+
"remote": { "id": "apple/swift-swift" } },
11+
"lldb": {
12+
"remote": { "id": "apple/swift-lldb" } },
13+
"cmark": {
14+
"remote": { "id": "apple/swift-cmark" } },
15+
"llbuild": {
16+
"remote": { "id": "apple/swift-llbuild" } },
17+
"swiftpm": {
18+
"remote": { "id": "apple/swift-package-manager" } },
19+
"compiler-rt": {
20+
"remote": { "id": "apple/swift-compiler-rt" } },
21+
"swift-corelibs-xctest": {
22+
"remote": { "id": "apple/swift-corelibs-xctest" } },
23+
"swift-corelibs-foundation": {
24+
"remote": { "id": "apple/swift-corelibs-foundation" } },
25+
"swift-corelibs-libdispatch": {
26+
"remote": { "id": "apple/swift-corelibs-libdispatch" } },
27+
"swift-integration-tests": {
28+
"remote": { "id": "apple/swift-integration-tests" } }
1729
},
1830
"default-branch-scheme": "master",
1931
"branch-schemes": {

0 commit comments

Comments
 (0)