@@ -56,26 +56,32 @@ def update_working_copy(repo_path, branch):
56
56
57
57
def obtain_additional_swift_sources (
58
58
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' ]
60
61
if dir_name in skip_repositories :
61
62
print ("--- Skipping '" + dir_name + "' ---" )
62
63
continue
63
64
with shell .pushd (SWIFT_SOURCE_ROOT , dry_run = False ,
64
65
echo = False ):
65
66
if not os .path .isdir (os .path .join (dir_name , ".git" )):
66
67
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
69
75
else :
70
- remote = config ["https_clone_pattern" ] % repo
76
+ remote = config ['https-clone-pattern' ] % repo
71
77
if skip_history :
72
78
shell .call (['git' , 'clone' , '--recursive' , '--depth' , '1' ,
73
79
remote , dir_name ], echo = False )
74
80
else :
75
81
shell .call (['git' , 'clone' , '--recursive' , remote ,
76
82
dir_name ], echo = False )
77
83
if branch :
78
- for config_branch_name in config ['branch_names ' ]:
84
+ for config_branch_name in config ['branch-names ' ]:
79
85
if branch not in config [config_branch_name ]['aliases' ]:
80
86
continue
81
87
repo_branch = \
@@ -91,9 +97,9 @@ def obtain_additional_swift_sources(
91
97
92
98
93
99
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 \' ' )
97
103
98
104
# Then make sure the alias names used by our branches are unique.
99
105
#
@@ -102,7 +108,7 @@ def validate_config(config):
102
108
# the union of the sets. We have uniqueness if the length of the union
103
109
# equals the length of the sum of the counts.
104
110
data = [(len (config [branch ]['aliases' ]), set (config [branch ]['aliases' ]))
105
- for branch in config ['branch_names ' ]]
111
+ for branch in config ['branch-names ' ]]
106
112
result = reduce (lambda acc , x : (acc [0 ] + x [0 ], acc [1 ] | x [1 ]), data ,
107
113
(0 , set ([])))
108
114
if result [0 ] == len (result [1 ]):
@@ -153,6 +159,11 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
153
159
config = json .load (f )
154
160
validate_config (config )
155
161
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
+
156
167
if clone or clone_with_ssh :
157
168
obtain_additional_swift_sources (
158
169
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.""")
163
174
print ("--- Skipping '" + dir_name + "' ---" )
164
175
continue
165
176
if branch :
166
- for config_branch_name in config ['branch_names ' ]:
177
+ for config_branch_name in config ['branch-names ' ]:
167
178
if branch not in config [config_branch_name ]['aliases' ]:
168
179
continue
169
180
repo_branch = config [config_branch_name ]['repos' ][dir_name ]
0 commit comments