Skip to content

Commit ba7b458

Browse files
committed
update-checkout: handle --skip-repository option
1 parent 21bd961 commit ba7b458

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ def check_parallel_results(results, op):
7575

7676

7777
def confirm_tag_in_repo(tag, repo_name):
78+
"""Confirm that a given tag exists in a git repository. This function
79+
assumes that the repository is already a current working directory before
80+
it's called.
81+
82+
Args:
83+
tag (str): tag to look up in the repository
84+
repo_name (str): name the repository for the look up, used for logging
85+
86+
Returns:
87+
str: returns `tag` argument value or `None` if the tag doesn't exist.
88+
"""
89+
7890
tag_exists = shell.capture(['git', 'ls-remote', '--tags',
7991
'origin', tag], echo=False)
8092
if not tag_exists:
@@ -255,10 +267,11 @@ def update_single_repository(pool_args):
255267
return value
256268

257269

258-
def get_timestamp_to_match(args):
259-
if not args.match_timestamp:
270+
def get_timestamp_to_match(match_timestamp, source_root):
271+
# type: (str, str) -> str | None
272+
if not match_timestamp:
260273
return None
261-
with shell.pushd(os.path.join(args.source_root, "swift"),
274+
with shell.pushd(os.path.join(source_root, "swift"),
262275
dry_run=False, echo=False):
263276
return shell.capture(["git", "log", "-1", "--format=%cI"],
264277
echo=False).strip()
@@ -289,7 +302,7 @@ def get_scheme_map(config, scheme_name):
289302

290303
def update_all_repositories(args, config, scheme_name, scheme_map, cross_repos_pr):
291304
pool_args = []
292-
timestamp = get_timestamp_to_match(args)
305+
timestamp = get_timestamp_to_match(args.match_timestamp, args.source_root)
293306
for repo_name in config['repos'].keys():
294307
if repo_name in args.skip_repository_list:
295308
print("Skipping update of '" + repo_name + "', requested by user")
@@ -498,9 +511,15 @@ def full_target_name(repository, target):
498511
raise RuntimeError('Cannot determine if %s is a branch or a tag' % target)
499512

500513

501-
def skip_list_for_platform(config, all_repos):
502-
if all_repos:
503-
return [] # Do not skip any platform-specific repositories
514+
def skip_list_for_platform(config):
515+
"""Computes a list of repositories to skip when updating or cloning.
516+
517+
Args:
518+
config (Dict[str, Any]): deserialized `update-checkout-config.json`
519+
520+
Returns:
521+
List[str]: a resulting list of repositories to skip.
522+
"""
504523

505524
# If there is a platforms key only include the repo if the
506525
# platform is in the list
@@ -628,7 +647,6 @@ def main():
628647
skip_tags = args.skip_tags
629648
scheme_name = args.scheme
630649
github_comment = args.github_comment
631-
all_repos = args.all_repositories
632650

633651
with open(args.config) as f:
634652
config = json.load(f)
@@ -649,8 +667,19 @@ def main():
649667

650668
scheme_map = get_scheme_map(config, scheme_name)
651669

670+
clone_results = None
671+
if clone or clone_with_ssh:
672+
skip_repo_list = skip_list_for_platform(config)
673+
skip_repo_list.extend(args.skip_repository_list)
674+
clone_results = obtain_all_additional_swift_sources(args, config,
675+
clone_with_ssh,
676+
scheme_name,
677+
skip_history,
678+
skip_tags,
679+
skip_repo_list)
680+
652681
swift_repo_path = os.path.join(args.source_root, 'swift')
653-
if os.path.exists(swift_repo_path):
682+
if not 'swift' in skip_repo_list and os.path.exists(swift_repo_path):
654683
with shell.pushd(swift_repo_path, dry_run=False, echo=True):
655684
# Check if `swift` repo itself needs to switch to a cross-repo branch.
656685
branch_name, cross_repo = get_branch_for_repo(config, 'swift',
@@ -675,17 +704,6 @@ def main():
675704
dump_repo_hashes(args, config, args.dump_hashes_config)
676705
return (None, None)
677706

678-
clone_results = None
679-
if clone or clone_with_ssh:
680-
skip_repo_list = skip_list_for_platform(config, all_repos)
681-
skip_repo_list.extend(args.skip_repository_list)
682-
clone_results = obtain_all_additional_swift_sources(args, config,
683-
clone_with_ssh,
684-
scheme_name,
685-
skip_history,
686-
skip_tags,
687-
skip_repo_list)
688-
689707
# Quick check whether somebody is calling update in an empty directory
690708
directory_contents = os.listdir(args.source_root)
691709
if not ('cmark' in directory_contents or

0 commit comments

Comments
 (0)