@@ -59,6 +59,9 @@ def clamp(n, _min, _max):
59
59
return max (_min , min (n , _max ))
60
60
61
61
62
+ EXIT_ON_ERROR_MSG = "Exiting via error (--exit-on-error passed)"
63
+
64
+
62
65
@click .command (name = "sync" )
63
66
@click .argument (
64
67
"repo_terms" , type = click .STRING , nargs = - 1 , shell_complete = get_repo_completions
@@ -71,7 +74,15 @@ def clamp(n, _min, _max):
71
74
help = "Specify config" ,
72
75
shell_complete = get_config_file_completions ,
73
76
)
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 :
75
86
if config :
76
87
configs = load_configs ([config ])
77
88
else :
@@ -95,7 +106,19 @@ def sync(repo_terms, config):
95
106
else :
96
107
found_repos = configs
97
108
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 )
99
122
100
123
101
124
def progress_cb (output , timestamp ):
0 commit comments