From a5dfc30461b58a1047fbd33ff5fe48452e1de317 Mon Sep 17 00:00:00 2001 From: Nicholas Devenish Date: Thu, 22 Jun 2017 12:32:11 +0100 Subject: [PATCH] Don't just silently fail if git fails This prints a message to the sublime text console, passing on any messages from git, if the command returns an error code. Previously this just failed silently, making it look like the plugin just didn't work. --- git-blame.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-blame.py b/git-blame.py index 6923a76..9ad115d 100644 --- a/git-blame.py +++ b/git-blame.py @@ -61,9 +61,12 @@ def get_blame(self, line, path): return shell(["git", "blame", "--minimal", "-w", "-L {0},{0}".format(line), path], cwd=os.path.dirname(os.path.realpath(path)), - startupinfo=si) + startupinfo=si, + stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + print("Git blame: git error {}:\n{}".format(e.returncode, e.output.decode("UTF-8"))) except Exception as e: - return + print("Git blame: Unexpected error:", e) def parse_blame(self, blame): sha, file_path, user, date, time, tz_offset, *_ = blame.decode('utf-8').split()