1111from libvcs .sync .git import GitSync
1212from libvcs .url import registry as url_tools
1313
14+ from .. import exc
1415from ..config import filter_repos , find_config_files , load_configs
1516
1617log = logging .getLogger (__name__ )
@@ -55,7 +56,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
5556
5657
5758def sync (
58- repo_patterns : t . List [str ],
59+ repo_patterns : list [str ],
5960 config : pathlib .Path ,
6061 exit_on_error : bool ,
6162 parser : t .Optional [
@@ -91,8 +92,8 @@ def sync(
9192 for repo in found_repos :
9293 try :
9394 update_repo (repo )
94- except Exception :
95- print (
95+ except Exception as e : # noqa: PERF203
96+ log . info (
9697 f'Failed syncing { repo .get ("name" )} ' ,
9798 )
9899 if log .isEnabledFor (logging .DEBUG ):
@@ -102,8 +103,7 @@ def sync(
102103 if exit_on_error :
103104 if parser is not None :
104105 parser .exit (status = 1 , message = EXIT_ON_ERROR_MSG )
105- else :
106- raise SystemExit (EXIT_ON_ERROR_MSG )
106+ raise SystemExit (EXIT_ON_ERROR_MSG ) from e
107107
108108
109109def progress_cb (output : str , timestamp : datetime ) -> None :
@@ -124,6 +124,11 @@ def guess_vcs(url: str) -> t.Optional[VCSLiteral]:
124124 return t .cast (VCSLiteral , vcs_matches [0 ].vcs )
125125
126126
127+ class CouldNotGuessVCSFromURL (exc .VCSPullException ):
128+ def __init__ (self , repo_url : str , * args : object , ** kwargs : object ) -> None :
129+ return super ().__init__ (f"Could not automatically determine VCS for { repo_url } " )
130+
131+
127132def update_repo (
128133 repo_dict : t .Any ,
129134 # repo_dict: Dict[str, Union[str, Dict[str, GitRemote], pathlib.Path]]
@@ -138,9 +143,7 @@ def update_repo(
138143 if repo_dict .get ("vcs" ) is None :
139144 vcs = guess_vcs (url = repo_dict ["url" ])
140145 if vcs is None :
141- raise Exception (
142- f'Could not automatically determine VCS for { repo_dict ["url" ]} '
143- )
146+ raise CouldNotGuessVCSFromURL (repo_url = repo_dict ["url" ])
144147
145148 repo_dict ["vcs" ] = vcs
146149
0 commit comments