Skip to content

Commit cb32792

Browse files
committed
update_checkout.py: Add support for tags and optional repositories.
- Update --reset-to-remote to support tags. - Add optional platform entry to a repository. This allows specifying which platforms a repo should be checked out on.
1 parent 3b2ebee commit cb32792

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

utils/update_checkout/update-checkout-config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
"ninja": {
3434
"remote": { "id": "ninja-build/ninja" } },
3535
"icu": {
36-
"remote": { "id": "unicode-org/icu" } }
36+
"remote": { "id": "unicode-org/icu" },
37+
"platforms": [ "Linux" ]
38+
}
3739
},
3840
"default-branch-scheme": "master",
3941
"branch-schemes": {

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import argparse
1414
import json
1515
import os
16+
import platform
1617
import re
1718
import sys
1819
import traceback
@@ -131,8 +132,8 @@ def update_single_repository(args):
131132
# If we were asked to reset to the specified branch, do the hard
132133
# reset and return.
133134
if checkout_target and reset_to_remote and not cross_repo:
134-
shell.run(['git', 'reset', '--hard',
135-
"origin/%s" % checkout_target], echo=True)
135+
full_target = full_target_name('origin', checkout_target)
136+
shell.run(['git', 'reset', '--hard', full_target], echo=True)
136137
return
137138

138139
# Query whether we have a "detached HEAD", which will mean that
@@ -371,6 +372,37 @@ def validate_config(config):
371372
'aliases?!')
372373

373374

375+
def full_target_name(repository, target):
376+
tag = shell.capture(["git", "tag", "-l", target], echo=True).strip()
377+
if tag == target:
378+
return tag
379+
380+
branch = shell.capture(["git", "branch", "--list", target],
381+
echo=True).strip().replace("* ", "")
382+
if branch == target:
383+
name = "%s/%s" % (repository, target)
384+
return name
385+
386+
raise RuntimeError('Cannot determine if %s is a branch or a tag' % target)
387+
388+
389+
def skip_list_for_platform(config):
390+
# If there is a platforms key only include the repo if the
391+
# plaform is in the list
392+
skip_list = []
393+
platform_name = platform.system()
394+
395+
for repo_name, repo_info in config['repos'].items():
396+
if 'platforms' in repo_info:
397+
if platform_name not in repo_info['platforms']:
398+
print("Skipping", repo_name, "on", platform_name)
399+
skip_list.append(repo_name)
400+
else:
401+
print("Including", repo_name, "on", platform_name)
402+
403+
return skip_list
404+
405+
374406
def main():
375407
freeze_support()
376408
parser = argparse.ArgumentParser(
@@ -494,7 +526,8 @@ def main():
494526
if scheme is None:
495527
scheme = config['default-branch-scheme']
496528

497-
skip_repo_list = args.skip_repository_list
529+
skip_repo_list = skip_list_for_platform(config)
530+
skip_repo_list.extend(args.skip_repository_list)
498531
clone_results = obtain_all_additional_swift_sources(args, config,
499532
clone_with_ssh,
500533
scheme,

0 commit comments

Comments
 (0)