1818logger = get_logger (__name__ )
1919
2020_SSH_HOST_KEY_MSGS = ("host key verification failed" , "authenticity of host" )
21+ _EXTERNALS_QUERY_TIMEOUT = 30
2122
2223
2324# As a cli tool, we can safely assume this remains stable during the runtime, caching for speed is better
@@ -45,11 +46,13 @@ def _raise_if_ssh_host_key_error(url: str, exc: SubprocessCommandError) -> None:
4546 """Raise a helpful RuntimeError if *exc* looks like an SSH host-key failure."""
4647 stderr_lower = exc .stderr .lower ()
4748 if any (msg in stderr_lower for msg in _SSH_HOST_KEY_MSGS ):
49+ parsed = urlparse (url )
50+ host_only = parsed .hostname or url
4851 target = _ssh_target_from_url (url )
4952 raise RuntimeError (
5053 f"SSH host key verification failed while connecting to '{ url } '.\n "
5154 "Add the host to your known hosts file, for example by running:\n "
52- f" ssh-keyscan { target } >> ~/.ssh/known_hosts\n "
55+ f" ssh-keyscan { host_only } >> ~/.ssh/known_hosts\n "
5356 "Or test the SSH connection manually:\n "
5457 f" ssh -T { target } "
5558 ) from exc
@@ -134,7 +137,7 @@ def list_of_tags(self) -> list[str]:
134137 )
135138 except SubprocessCommandError as exc :
136139 _raise_if_ssh_host_key_error (self ._remote , exc )
137- raise
140+ return []
138141 return [
139142 str (tag ).strip ("/\r " ) for tag in result .stdout .decode ().split ("\n " ) if tag
140143 ]
@@ -205,7 +208,11 @@ def is_svn(self) -> bool:
205208 """Check if is SVN."""
206209 try :
207210 with in_directory (self ._path ):
208- run_on_cmdline (logger , ["svn" , "info" , "--non-interactive" ])
211+ run_on_cmdline (
212+ logger ,
213+ ["svn" , "info" , "--non-interactive" ],
214+ env = _extend_env_for_non_interactive_mode (),
215+ )
209216 return True
210217 except (SubprocessCommandError , RuntimeError ):
211218 return False
@@ -222,6 +229,7 @@ def externals(self) -> list[External]:
222229 "svn:externals" ,
223230 "-R" ,
224231 ],
232+ env = _extend_env_for_non_interactive_mode (),
225233 )
226234 repo_root = SvnRepo .get_info_from_target ()["Repository Root" ]
227235 return SvnRepo ._parse_externals (
@@ -231,11 +239,23 @@ def externals(self) -> list[External]:
231239 @staticmethod
232240 def externals_from_url (url : str , revision : str = "" ) -> list [External ]:
233241 """Get list of externals from a remote SVN URL."""
234- cmd = ["svn" , "--non-interactive" , "propget" , "svn:externals" , "-R" ]
242+ cmd = [
243+ "svn" ,
244+ "--non-interactive" ,
245+ "propget" ,
246+ "svn:externals" ,
247+ "--depth" ,
248+ "immediates" ,
249+ ]
235250 if revision :
236251 cmd += ["--revision" , revision ]
237252 cmd += [url ]
238- result = run_on_cmdline (logger , cmd , env = _extend_env_for_non_interactive_mode ())
253+ result = run_on_cmdline (
254+ logger ,
255+ cmd ,
256+ env = _extend_env_for_non_interactive_mode (),
257+ timeout = _EXTERNALS_QUERY_TIMEOUT ,
258+ )
239259 repo_root = SvnRepo .get_info_from_target (url )["Repository Root" ]
240260 normalized = SvnRepo ._normalize_url_prefix (result .stdout .decode (), url )
241261 return SvnRepo ._parse_externals (normalized , repo_root )
@@ -518,7 +538,9 @@ def create_diff(
518538 )
519539
520540 with in_directory (self ._path ):
521- patch_text = run_on_cmdline (logger , cmd ).stdout
541+ patch_text = run_on_cmdline (
542+ logger , cmd , env = _extend_env_for_non_interactive_mode ()
543+ ).stdout
522544
523545 if not patch_text .strip ():
524546 return Patch .empty ().convert_type (PatchType .SVN )
@@ -537,6 +559,7 @@ def get_username(self) -> str:
537559 "author" ,
538560 self ._path ,
539561 ],
562+ env = _extend_env_for_non_interactive_mode (),
540563 )
541564 return str (result .stdout .decode ().strip ())
542565 except SubprocessCommandError :
0 commit comments