Merge lp:~jelmer/brz/git-host-key-verification into lp:brz/3.2

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-host-key-verification
Merge into: lp:brz/3.2
Diff against target: 69 lines (+24/-0)
2 files modified
breezy/git/remote.py (+6/-0)
breezy/git/tests/test_remote.py (+18/-0)
To merge this branch: bzr merge lp:~jelmer/brz/git-host-key-verification
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+415805@code.launchpad.net

Commit message

Special case some more Git error messages.

Description of the change

Special case some more Git error messages.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/remote.py'
2--- breezy/git/remote.py 2022-01-16 17:15:16 +0000
3+++ breezy/git/remote.py 2022-02-18 17:09:50 +0000
4@@ -35,6 +35,7 @@
5 from ..errors import (
6 AlreadyBranchError,
7 BzrError,
8+ ConnectionReset,
9 DivergedBranches,
10 InProcessTransport,
11 InvalidRevisionId,
12@@ -44,6 +45,7 @@
13 NotBranchError,
14 NotLocalUrl,
15 PermissionDenied,
16+ TransportError,
17 UninitializableFormat,
18 )
19 from ..revision import NULL_REVISION
20@@ -215,6 +217,10 @@
21 m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
22 if m:
23 return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
24+ if message == 'Host key verification failed.':
25+ return TransportError('Host key verification failed')
26+ if message == '[Errno 104] Connection reset by peer':
27+ return ConnectionReset(message)
28 # Don't know, just return it to the user as-is
29 return RemoteGitError(message)
30
31
32=== modified file 'breezy/git/tests/test_remote.py'
33--- breezy/git/tests/test_remote.py 2022-01-24 20:22:05 +0000
34+++ breezy/git/tests/test_remote.py 2022-02-18 17:09:50 +0000
35@@ -23,10 +23,12 @@
36
37 from ...controldir import ControlDir
38 from ...errors import (
39+ ConnectionReset,
40 DivergedBranches,
41 NotBranchError,
42 NoSuchTag,
43 PermissionDenied,
44+ TransportError,
45 )
46
47 from ...tests import (
48@@ -164,6 +166,22 @@
49 'GitLab: You are not allowed to push code to '
50 'protected branches on this project.')))
51
52+ def test_host_key_verification(self):
53+ self.assertEqual(
54+ TransportError('Host key verification failed'),
55+ parse_git_error(
56+ 'url',
57+ RemoteGitError(
58+ 'Host key verification failed.')))
59+
60+ def test_connection_reset_by_peer(self):
61+ self.assertEqual(
62+ ConnectionReset('[Errno 104] Connection reset by peer'),
63+ parse_git_error(
64+ 'url',
65+ RemoteGitError(
66+ '[Errno 104] Connection reset by peer')))
67+
68
69 class ParseHangupTests(TestCase):
70

Subscribers

People subscribed via source and target branches