2727SCRIPT_DIR = os .path .dirname (SCRIPT_FILE )
2828
2929
30+ class SkippedReason :
31+ def __init__ (self , repo_name : str , reason : str ):
32+ self .repo_name = repo_name
33+ self .reason = reason
34+
35+ @staticmethod
36+ def print_skipped_repositories (skipped_reasons : List ["SkippedReason" ], step : str ):
37+ if not skipped_reasons :
38+ return
39+ print (f"Skipped { step } :" )
40+ for reason in skipped_reasons :
41+ print (f" '{ reason .repo_name } ' - { reason .reason } " )
42+
43+
3044def confirm_tag_in_repo (repo_path : str , tag : str , repo_name : str ) -> Optional [str ]:
3145 """Confirm that a given tag exists in a git repository. This function
3246 assumes that the repository is already a current working directory before
@@ -356,24 +370,19 @@ def update_all_repositories(
356370 scheme_map : Optional [Dict [str , Any ]],
357371 cross_repos_pr : Dict [str , str ],
358372):
373+ skipped_repositories = []
359374 pool_args : List [UpdateArguments ] = []
360375 timestamp = get_timestamp_to_match (args .match_timestamp , args .source_root )
361376 for repo_name in config ['repos' ].keys ():
362377 if repo_name in args .skip_repository_list :
363- print ( "Skipping update of '" + repo_name + "', requested by user" )
378+ skipped_repositories . append ( SkippedReason ( repo_name , " requested by user",) )
364379 continue
365380
366381 # If the repository is not listed in the branch-scheme, skip it.
367382 if scheme_map and repo_name not in scheme_map :
368383 # If the repository exists locally, notify we are skipping it.
369384 if os .path .isdir (os .path .join (args .source_root , repo_name )):
370- print (
371- "Skipping update of '"
372- + repo_name
373- + "', repository not listed in the '"
374- + scheme_name
375- + "' branch-scheme"
376- )
385+ skipped_repositories .append (SkippedReason (repo_name , f"repository not listed in the { scheme_name } branch-scheme" ))
377386 continue
378387
379388 my_args = UpdateArguments (
@@ -400,7 +409,7 @@ def update_all_repositories(
400409 for repo_name in locked_repositories
401410 ]
402411 _move_llvm_project_to_first_index (pool_args )
403- return ParallelRunner (update_single_repository , pool_args , args .n_processes ).run ()
412+ return skipped_repositories , ParallelRunner (update_single_repository , pool_args , args .n_processes ).run ()
404413
405414
406415def obtain_additional_swift_sources (pool_args : AdditionalSwiftSourcesArguments ):
@@ -451,12 +460,12 @@ def obtain_all_additional_swift_sources(
451460 scheme_name : str ,
452461 skip_repository_list : List [str ],
453462):
463+ skipped_repositories = []
454464 pool_args = []
455465 for repo_name , repo_info in config ['repos' ].items ():
456466 repo_path = os .path .join (args .source_root , repo_name )
457467 if repo_name in skip_repository_list :
458- print ("Skipping clone of '" + repo_name + "', requested by "
459- "user" )
468+ skipped_repositories .append (SkippedReason (repo_name , "requested by user" ))
460469 continue
461470
462471 if args .use_submodules :
@@ -472,8 +481,7 @@ def obtain_all_additional_swift_sources(
472481 repo_exists = os .path .isdir (os .path .join (repo_path , ".git" ))
473482
474483 if repo_exists :
475- print ("Skipping clone of '" + repo_name + "', directory "
476- "already exists" )
484+ skipped_repositories .append (SkippedReason (repo_name , "directory already exists" ))
477485 continue
478486
479487 # If we have a url override, use that url instead of
@@ -528,13 +536,13 @@ def obtain_all_additional_swift_sources(
528536 # Only use `ParallelRunner` when submodules are not used, since `.git` dir
529537 # can't be accessed concurrently.
530538 if args .use_submodules :
531- return
539+ return [], None
532540 if not pool_args :
533541 print ("Not cloning any repositories." )
534- return
542+ return [], None
535543
536544 _move_llvm_project_to_first_index (pool_args )
537- return ParallelRunner (
545+ return skipped_repositories , ParallelRunner (
538546 obtain_additional_swift_sources , pool_args , args .n_processes
539547 ).run ()
540548
@@ -735,9 +743,10 @@ def main() -> int:
735743 if args .clone or args .clone_with_ssh :
736744 skip_repo_list = skip_list_for_platform (config , args .all_repositories )
737745 skip_repo_list .extend (args .skip_repository_list )
738- clone_results = obtain_all_additional_swift_sources (args , config ,
739- scheme_name ,
740- skip_repo_list )
746+ skipped_repositories , clone_results = obtain_all_additional_swift_sources (
747+ args , config , scheme_name , skip_repo_list
748+ )
749+ SkippedReason .print_skipped_repositories (skipped_repositories , "clone" )
741750
742751 swift_repo_path = os .path .join (args .source_root , 'swift' )
743752 if 'swift' not in skip_repo_list and os .path .exists (swift_repo_path ):
@@ -776,8 +785,10 @@ def main() -> int:
776785 print ("You don't have all swift sources. "
777786 "Call this script with --clone to get them." )
778787
779- update_results = update_all_repositories (args , config , scheme_name ,
788+ skipped_repositories , update_results = update_all_repositories (args , config , scheme_name ,
780789 scheme_map , cross_repos_pr )
790+ SkippedReason .print_skipped_repositories (skipped_repositories , "update" )
791+
781792 fail_count = 0
782793 fail_count += ParallelRunner .check_results (clone_results , "CLONE" )
783794 fail_count += ParallelRunner .check_results (update_results , "UPDATE" )
0 commit comments