Skip to content

Commit d1e78f5

Browse files
committed
Merge pull request #2927 from gottesmm/finish-fixing-update-checkout-to-use-config-file
Finish fixing update checkout to use config file
2 parents b0862e2 + 03fc193 commit d1e78f5

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

utils/update-checkout

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,32 @@ def update_working_copy(repo_path, branch):
5656

5757
def obtain_additional_swift_sources(
5858
config, with_ssh, branch, skip_history, skip_repositories):
59-
for dir_name, repo in config['repositories'].items():
59+
for dir_name, repo_info in config['repositories'].items():
60+
repo = repo_info['name']
6061
if dir_name in skip_repositories:
6162
print("--- Skipping '" + dir_name + "' ---")
6263
continue
6364
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False,
6465
echo=False):
6566
if not os.path.isdir(os.path.join(dir_name, ".git")):
6667
print("--- Cloning '" + dir_name + "' ---")
67-
if with_ssh is True or "https_clone_pattern" not in config:
68-
remote = config["ssh_clone_pattern"] % repo
68+
69+
# If we have a url override, use that url instead of
70+
# interpolating.
71+
if 'url' in repo_info:
72+
remote = repo_info['url']
73+
elif with_ssh is True or 'https-clone-pattern' not in config:
74+
remote = config['ssh-clone-pattern'] % repo
6975
else:
70-
remote = config["https_clone_pattern"] % repo
76+
remote = config['https-clone-pattern'] % repo
7177
if skip_history:
7278
shell.call(['git', 'clone', '--recursive', '--depth', '1',
7379
remote, dir_name], echo=False)
7480
else:
7581
shell.call(['git', 'clone', '--recursive', remote,
7682
dir_name], echo=False)
7783
if branch:
78-
for config_branch_name in config['branch_names']:
84+
for config_branch_name in config['branch-names']:
7985
if branch not in config[config_branch_name]['aliases']:
8086
continue
8187
repo_branch = \
@@ -91,9 +97,9 @@ def obtain_additional_swift_sources(
9197

9298

9399
def validate_config(config):
94-
# Make sure that our branch_names are unique.
95-
if len(config['branch_names']) != len(set(config['branch_names'])):
96-
raise RuntimeError('Configuration file has duplicate \'branch_names\'')
100+
# Make sure that our branch-names are unique.
101+
if len(config['branch-names']) != len(set(config['branch-names'])):
102+
raise RuntimeError('Configuration file has duplicate \'branch-names\'')
97103

98104
# Then make sure the alias names used by our branches are unique.
99105
#
@@ -102,7 +108,7 @@ def validate_config(config):
102108
# the union of the sets. We have uniqueness if the length of the union
103109
# equals the length of the sum of the counts.
104110
data = [(len(config[branch]['aliases']), set(config[branch]['aliases']))
105-
for branch in config['branch_names']]
111+
for branch in config['branch-names']]
106112
result = reduce(lambda acc, x: (acc[0] + x[0], acc[1] | x[1]), data,
107113
(0, set([])))
108114
if result[0] == len(result[1]):
@@ -153,6 +159,11 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
153159
config = json.load(f)
154160
validate_config(config)
155161

162+
# If branch is None, default to using the default branch alias specified by
163+
# our configuration file.
164+
if branch is None:
165+
branch = config['default-branch-alias']
166+
156167
if clone or clone_with_ssh:
157168
obtain_additional_swift_sources(
158169
config, clone_with_ssh, branch, skip_history, args.skip_repository)
@@ -163,7 +174,7 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
163174
print("--- Skipping '" + dir_name + "' ---")
164175
continue
165176
if branch:
166-
for config_branch_name in config['branch_names']:
177+
for config_branch_name in config['branch-names']:
167178
if branch not in config[config_branch_name]['aliases']:
168179
continue
169180
repo_branch = config[config_branch_name]['repos'][dir_name]

utils/update-checkout-config.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
"ssh_clone_pattern": "[email protected]:%s.git",
3-
"https_clone_pattern": "https://github.com/%s.git",
2+
"ssh-clone-pattern": "[email protected]:%s.git",
3+
"https-clone-pattern": "https://github.com/%s.git",
44
"repositories" : {
5-
"llvm": "apple/swift-llvm",
6-
"clang": "apple/swift-clang",
7-
"swift": "apple/swift-swift",
8-
"lldb": "apple/swift-lldb",
9-
"cmark": "apple/swift-cmark",
10-
"llbuild": "apple/swift-llbuild",
11-
"swiftpm": "apple/swift-package-manager",
12-
"compiler-rt": "apple/swift-compiler-rt",
13-
"swift-corelibs-xctest": "apple/swift-corelibs-xctest",
14-
"swift-corelibs-foundation": "apple/swift-corelibs-foundation",
15-
"swift-corelibs-libdispatch": "apple/swift-corelibs-libdispatch",
16-
"swift-integration-tests": "apple/swift-integration-tests"
5+
"llvm": { "name": "apple/swift-llvm" },
6+
"clang": { "name": "apple/swift-clang" },
7+
"swift": { "name": "apple/swift-swift" },
8+
"lldb": { "name": "apple/swift-lldb" },
9+
"cmark": { "name": "apple/swift-cmark" },
10+
"llbuild": { "name": "apple/swift-llbuild" },
11+
"swiftpm": { "name": "apple/swift-package-manager" },
12+
"compiler-rt": { "name": "apple/swift-compiler-rt" },
13+
"swift-corelibs-xctest": { "name": "apple/swift-corelibs-xctest" },
14+
"swift-corelibs-foundation": { "name": "apple/swift-corelibs-foundation" },
15+
"swift-corelibs-libdispatch": { "name": "apple/swift-corelibs-libdispatch" },
16+
"swift-integration-tests": { "name": "apple/swift-integration-tests" }
1717
},
18-
"branch_names": ["master-branches", "next-branches", "swift-3.0-preview-1-branches"],
18+
"branch-names": ["master-branches", "next-branches", "swift-3.0-preview-1-branches"],
19+
"default-branch-alias": "master",
1920
"master-branches": {
2021
"aliases": ["master", "stable"],
2122
"repos": {

0 commit comments

Comments
 (0)