diff options
Diffstat (limited to 'git_command.py')
-rw-r--r-- | git_command.py | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/git_command.py b/git_command.py index d06fc77c..f8cb280c 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -12,6 +12,7 @@ | |||
12 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | import functools | ||
15 | import os | 16 | import os |
16 | import re | 17 | import re |
17 | import sys | 18 | import sys |
@@ -45,7 +46,6 @@ LAST_CWD = None | |||
45 | _ssh_proxy_path = None | 46 | _ssh_proxy_path = None |
46 | _ssh_sock_path = None | 47 | _ssh_sock_path = None |
47 | _ssh_clients = [] | 48 | _ssh_clients = [] |
48 | _ssh_version = None | ||
49 | 49 | ||
50 | 50 | ||
51 | def _run_ssh_version(): | 51 | def _run_ssh_version(): |
@@ -64,16 +64,14 @@ def _parse_ssh_version(ver_str=None): | |||
64 | return () | 64 | return () |
65 | 65 | ||
66 | 66 | ||
67 | @functools.lru_cache(maxsize=None) | ||
67 | def ssh_version(): | 68 | def ssh_version(): |
68 | """return ssh version as a tuple""" | 69 | """return ssh version as a tuple""" |
69 | global _ssh_version | 70 | try: |
70 | if _ssh_version is None: | 71 | return _parse_ssh_version() |
71 | try: | 72 | except subprocess.CalledProcessError: |
72 | _ssh_version = _parse_ssh_version() | 73 | print('fatal: unable to detect ssh version', file=sys.stderr) |
73 | except subprocess.CalledProcessError: | 74 | sys.exit(1) |
74 | print('fatal: unable to detect ssh version', file=sys.stderr) | ||
75 | sys.exit(1) | ||
76 | return _ssh_version | ||
77 | 75 | ||
78 | 76 | ||
79 | def ssh_sock(create=True): | 77 | def ssh_sock(create=True): |
@@ -125,18 +123,14 @@ def terminate_ssh_clients(): | |||
125 | _ssh_clients = [] | 123 | _ssh_clients = [] |
126 | 124 | ||
127 | 125 | ||
128 | _git_version = None | ||
129 | |||
130 | |||
131 | class _GitCall(object): | 126 | class _GitCall(object): |
127 | @functools.lru_cache(maxsize=None) | ||
132 | def version_tuple(self): | 128 | def version_tuple(self): |
133 | global _git_version | 129 | ret = Wrapper().ParseGitVersion() |
134 | if _git_version is None: | 130 | if ret is None: |
135 | _git_version = Wrapper().ParseGitVersion() | 131 | print('fatal: unable to detect git version', file=sys.stderr) |
136 | if _git_version is None: | 132 | sys.exit(1) |
137 | print('fatal: unable to detect git version', file=sys.stderr) | 133 | return ret |
138 | sys.exit(1) | ||
139 | return _git_version | ||
140 | 134 | ||
141 | def __getattr__(self, name): | 135 | def __getattr__(self, name): |
142 | name = name.replace('_', '-') | 136 | name = name.replace('_', '-') |