@@ -59,6 +59,9 @@ def clamp(n, _min, _max):
5959 return max (_min , min (n , _max ))
6060
6161
62+ EXIT_ON_ERROR_MSG = "Exiting via error (--exit-on-error passed)"
63+
64+
6265@click .command (name = "sync" )
6366@click .argument (
6467 "repo_terms" , type = click .STRING , nargs = - 1 , shell_complete = get_repo_completions
@@ -71,7 +74,15 @@ def clamp(n, _min, _max):
7174 help = "Specify config" ,
7275 shell_complete = get_config_file_completions ,
7376)
74- def sync (repo_terms , config ):
77+ @click .option (
78+ "exit_on_error" ,
79+ "--exit-on-error" ,
80+ "-x" ,
81+ is_flag = True ,
82+ default = False ,
83+ help = "Exit immediately when encountering an error syncing multiple repos" ,
84+ )
85+ def sync (repo_terms , config , exit_on_error : bool ) -> None :
7586 if config :
7687 configs = load_configs ([config ])
7788 else :
@@ -95,7 +106,19 @@ def sync(repo_terms, config):
95106 else :
96107 found_repos = configs
97108
98- list (map (update_repo , found_repos ))
109+ for repo in found_repos :
110+ try :
111+ update_repo (repo )
112+ except Exception :
113+ click .echo (
114+ f'Failed syncing { repo .get ("name" )} ' ,
115+ )
116+ if log .isEnabledFor (logging .DEBUG ):
117+ import traceback
118+
119+ traceback .print_exc ()
120+ if exit_on_error :
121+ raise click .ClickException (EXIT_ON_ERROR_MSG )
99122
100123
101124def progress_cb (output , timestamp ):
0 commit comments