mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Improve error logging for pygit2 SSH-based remotes
If libgit2 is compiled without libssh2, an "Unsupported URL protocol" GitError exception is raised. This commit catches this exception and, if the credentials are a keypair (which means SSH auth), logs an meaningful error message that will let the user know that libgit2 was probably not compiled with libssh2.
This commit is contained in:
parent
3c91459de2
commit
9d394dfe46
1 changed files with 15 additions and 1 deletions
|
@ -1147,7 +1147,21 @@ def update():
|
|||
except KeyError:
|
||||
# No credentials configured for this repo
|
||||
pass
|
||||
fetch = origin.fetch()
|
||||
try:
|
||||
fetch = origin.fetch()
|
||||
except pygit2.errors.GitError as exc:
|
||||
# Using exc.__str__() here to avoid deprecation warning
|
||||
# when referencing exc.message
|
||||
if 'unsupported url protocol' in exc.__str__().lower() \
|
||||
and isinstance(repo.get('credentials'),
|
||||
pygit2.Keypair):
|
||||
log.error(
|
||||
'Unable to fetch SSH-based gitfs remote {0}. '
|
||||
'libgit2 must be compiled with libssh2 to support '
|
||||
'SSH authentication.'.format(repo['url'])
|
||||
)
|
||||
continue
|
||||
raise
|
||||
try:
|
||||
# pygit2.Remote.fetch() returns a dict in pygit2 < 0.21.0
|
||||
received_objects = fetch['received_objects']
|
||||
|
|
Loading…
Add table
Reference in a new issue