@@ -75,6 +75,18 @@ def check_parallel_results(results, op):
75
75
76
76
77
77
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
+
78
90
tag_exists = shell .capture (['git' , 'ls-remote' , '--tags' ,
79
91
'origin' , tag ], echo = False )
80
92
if not tag_exists :
@@ -255,10 +267,11 @@ def update_single_repository(pool_args):
255
267
return value
256
268
257
269
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 :
260
273
return None
261
- with shell .pushd (os .path .join (args . source_root , "swift" ),
274
+ with shell .pushd (os .path .join (source_root , "swift" ),
262
275
dry_run = False , echo = False ):
263
276
return shell .capture (["git" , "log" , "-1" , "--format=%cI" ],
264
277
echo = False ).strip ()
@@ -289,7 +302,7 @@ def get_scheme_map(config, scheme_name):
289
302
290
303
def update_all_repositories (args , config , scheme_name , scheme_map , cross_repos_pr ):
291
304
pool_args = []
292
- timestamp = get_timestamp_to_match (args )
305
+ timestamp = get_timestamp_to_match (args . match_timestamp , args . source_root )
293
306
for repo_name in config ['repos' ].keys ():
294
307
if repo_name in args .skip_repository_list :
295
308
print ("Skipping update of '" + repo_name + "', requested by user" )
@@ -498,9 +511,15 @@ def full_target_name(repository, target):
498
511
raise RuntimeError ('Cannot determine if %s is a branch or a tag' % target )
499
512
500
513
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
+ """
504
523
505
524
# If there is a platforms key only include the repo if the
506
525
# platform is in the list
@@ -628,7 +647,6 @@ def main():
628
647
skip_tags = args .skip_tags
629
648
scheme_name = args .scheme
630
649
github_comment = args .github_comment
631
- all_repos = args .all_repositories
632
650
633
651
with open (args .config ) as f :
634
652
config = json .load (f )
@@ -649,8 +667,19 @@ def main():
649
667
650
668
scheme_map = get_scheme_map (config , scheme_name )
651
669
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
+
652
681
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 ):
654
683
with shell .pushd (swift_repo_path , dry_run = False , echo = True ):
655
684
# Check if `swift` repo itself needs to switch to a cross-repo branch.
656
685
branch_name , cross_repo = get_branch_for_repo (config , 'swift' ,
@@ -675,17 +704,6 @@ def main():
675
704
dump_repo_hashes (args , config , args .dump_hashes_config )
676
705
return (None , None )
677
706
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
-
689
707
# Quick check whether somebody is calling update in an empty directory
690
708
directory_contents = os .listdir (args .source_root )
691
709
if not ('cmark' in directory_contents or
0 commit comments