|
17 | 17 | import re
|
18 | 18 | import sys
|
19 | 19 | import traceback
|
20 |
| - |
21 | 20 | from functools import reduce
|
22 | 21 | from multiprocessing import freeze_support
|
23 | 22 |
|
@@ -309,49 +308,42 @@ def obtain_all_additional_swift_sources(args, config, with_ssh, scheme_name,
|
309 | 308 | args.n_processes)
|
310 | 309 |
|
311 | 310 |
|
312 |
| -def dump_repo_hashes(config): |
| 311 | +def dump_repo_hashes(config, branch_scheme_name='repro'): |
313 | 312 | """
|
314 | 313 | Dumps the current state of the repo into a new config file that contains a
|
315 | 314 | master branch scheme with the relevant branches set to the appropriate
|
316 | 315 | hashes.
|
317 | 316 | """
|
318 |
| - branch_scheme_name = 'repro' |
319 | 317 | new_config = {}
|
320 | 318 | config_copy_keys = ['ssh-clone-pattern', 'https-clone-pattern', 'repos']
|
321 | 319 | for config_copy_key in config_copy_keys:
|
322 | 320 | new_config[config_copy_key] = config[config_copy_key]
|
323 | 321 | repos = {}
|
| 322 | + repos = repo_hashes(config) |
324 | 323 | branch_scheme = {'aliases': [branch_scheme_name], 'repos': repos}
|
325 | 324 | new_config['branch-schemes'] = {branch_scheme_name: branch_scheme}
|
326 |
| - for repo_name, repo_info in sorted(config['repos'].items(), |
327 |
| - key=lambda x: x[0]): |
328 |
| - with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name), |
329 |
| - dry_run=False, |
330 |
| - echo=False): |
331 |
| - h = shell.capture(["git", "rev-parse", "HEAD"], |
332 |
| - echo=False).strip() |
333 |
| - repos[repo_name] = str(h) |
334 | 325 | json.dump(new_config, sys.stdout, indent=4)
|
335 | 326 |
|
336 | 327 |
|
337 |
| -def dump_hashes_config(args, config): |
338 |
| - branch_scheme_name = args.dump_hashes_config |
339 |
| - new_config = {} |
340 |
| - config_copy_keys = ['ssh-clone-pattern', 'https-clone-pattern', 'repos'] |
341 |
| - for config_copy_key in config_copy_keys: |
342 |
| - new_config[config_copy_key] = config[config_copy_key] |
| 328 | +def repo_hashes(config): |
343 | 329 | repos = {}
|
344 |
| - branch_scheme = {'aliases': [branch_scheme_name], 'repos': repos} |
345 |
| - new_config['branch-schemes'] = {args.dump_hashes_config: branch_scheme} |
346 | 330 | for repo_name, repo_info in sorted(config['repos'].items(),
|
347 | 331 | key=lambda x: x[0]):
|
348 |
| - with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name), |
349 |
| - dry_run=False, |
350 |
| - echo=False): |
351 |
| - h = shell.capture(["git", "rev-parse", "HEAD"], |
352 |
| - echo=False).strip() |
353 |
| - repos[repo_name] = str(h) |
354 |
| - json.dump(new_config, sys.stdout, indent=4) |
| 332 | + repo_path = os.path.join(SWIFT_SOURCE_ROOT, repo_name) |
| 333 | + if os.path.exists(repo_path): |
| 334 | + with shell.pushd(repo_path, dry_run=False, echo=False): |
| 335 | + h = shell.capture(["git", "rev-parse", "HEAD"], |
| 336 | + echo=False).strip() |
| 337 | + else: |
| 338 | + h = 'skip' |
| 339 | + repos[repo_name] = str(h) |
| 340 | + return repos |
| 341 | + |
| 342 | + |
| 343 | +def print_repo_hashes(config): |
| 344 | + repos = repo_hashes(config) |
| 345 | + for repo_name, repo_hash in repos.iteritems(): |
| 346 | + print("{:<35}: {:<35}".format(repo_name, repo_hash)) |
355 | 347 |
|
356 | 348 |
|
357 | 349 | def validate_config(config):
|
@@ -520,7 +512,7 @@ def main():
|
520 | 512 | return (None, None)
|
521 | 513 |
|
522 | 514 | if args.dump_hashes_config:
|
523 |
| - dump_hashes_config(args, config) |
| 515 | + dump_repo_hashes(config, args.dump_hashes_config) |
524 | 516 | return (None, None)
|
525 | 517 |
|
526 | 518 | cross_repos_pr = {}
|
@@ -563,4 +555,5 @@ def main():
|
563 | 555 | print("update-checkout failed, fix errors and try again")
|
564 | 556 | else:
|
565 | 557 | print("update-checkout succeeded")
|
| 558 | + print_repo_hashes(config) |
566 | 559 | sys.exit(fail_count)
|
0 commit comments