From df4f3a1b198c46750f89b80c8855d435079a04ec Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 4 Jul 2015 21:57:57 +0300 Subject: [PATCH] trezor-agent: automatic support for git identity The agent uses local 'git config', and chooses the url marked as "trezor = true". --- sshagent/trezor.py | 14 +++++--------- sshagent/trezor_agent.py | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/sshagent/trezor.py b/sshagent/trezor.py index a15c686..4bafab8 100644 --- a/sshagent/trezor.py +++ b/sshagent/trezor.py @@ -83,20 +83,15 @@ class Client(object): return (r, s) -def _split(s, *parts): - return re.match(regexp, s).groups() - - -_parts = [ +_identity_regexp = re.compile(''.join([ '^' r'(?:(?P.*)://)?', r'(?:(?P.*)@)?', r'(?P.*?)', r'(?::(?P\w*))?', - r'(?:/(?P.*))?', + r'(?P/.*)?', '$' -] -_identity_regexp = re.compile(''.join(_parts)) +])) def _string_to_identity(s): m = _identity_regexp.match(s) @@ -117,13 +112,14 @@ def _identity_to_string(identity): if identity.port: result.append(':' + identity.port) if identity.path: - result.append('/' + identity.path) + result.append(identity.path) return ''.join(result) def _get_address(identity): index = struct.pack('