From dac69aa386fe31f2079a42fd926c71879e37afec Mon Sep 17 00:00:00 2001 From: muxueqz Date: Thu, 9 Apr 2020 17:54:41 +0800 Subject: [PATCH] Fix: No prompt for the password, then an error #1 --- git-credential-pass.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/git-credential-pass.py b/git-credential-pass.py index 34270cd..aabcce1 100755 --- a/git-credential-pass.py +++ b/git-credential-pass.py @@ -52,13 +52,29 @@ if operation == "get": ) find_path = _find_path.decode('utf8').replace(password_store_path, '').strip('\n') - client = subprocess.check_output( - [ - 'pass', - 'show', - find_path, - ] - ) + try: + client = subprocess.check_output( + [ + 'pass', + 'show', + find_path, + ] + ) + except subprocess.CalledProcessError: + subprocess.check_output( + [ + 'xterm', '-e', + 'pass show "%s"' % find_path, + ] + ) + client = subprocess.check_output( + [ + 'pass', + 'show', + find_path, + ] + ) + extractor = client.decode('utf8').split('\n') repo_logins = {} repo_logins['login'] = ': '.join(extractor[1].split(': ')[1:])