Skip to content

Commit

Permalink
update-checkout supports --dump-hashes-config.
Browse files Browse the repository at this point in the history
The config can stored and passed to update-checkout with --config
recreating the same set of repos as at the time of the dump.
  • Loading branch information
gmilos committed Jan 13, 2017
1 parent 34099d4 commit 542fe0d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils/update-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,24 @@ def dump_repo_hashes(config):
echo=False).strip()
print(fmt.format(repo_name, h))

def dump_hashes_config(args, config):
branch_scheme_name = args.dump_hashes_config
new_config = {}
config_copy_keys = ['ssh-clone-pattern', 'https-clone-pattern', 'repos']
for config_copy_key in config_copy_keys:
new_config[config_copy_key] = config[config_copy_key]
repos = {}
branch_scheme = {'aliases': [branch_scheme_name], 'repos': repos}
new_config['branch-schemes'] = {args.dump_hashes_config: branch_scheme}
for repo_name, repo_info in sorted(config['repos'].items(),
key=lambda x: x[0]):
with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name),
dry_run=False,
echo=False):
h = shell.capture(["git", "rev-parse", "HEAD"],
echo=False).strip()
repos[repo_name] = str(h)
print(json.dumps(new_config, indent=4))

def validate_config(config):
# Make sure that our branch-names are unique.
Expand Down Expand Up @@ -317,6 +335,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
'--dump-hashes',
action='store_true',
help='Dump the git hashes of all repositories being tracked')
parser.add_argument(
'--dump-hashes-config',
help='Dump the git hashes of all repositories packaged into update-checkout-config.json',
metavar='BRANCH-SCHEME-NAME')
parser.add_argument(
"--tag",
help="""Check out each repository to the specified tag.""",
Expand Down Expand Up @@ -347,6 +369,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
dump_repo_hashes(config)
return (None, None)

if args.dump_hashes_config:
dump_hashes_config(args, config)
return (None, None)

cross_repos_pr = {}
if github_comment:
regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)'
Expand Down

0 comments on commit 542fe0d

Please sign in to comment.