From 77ac61ce16ba016b713527ad337121817361acbd Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 29 Apr 2021 17:07:15 -0400 Subject: [PATCH] git-rb-catchup: handle running in non-git dirs better --- .bin/git-rb-catchup | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.bin/git-rb-catchup b/.bin/git-rb-catchup index 66b87a8..cb34e13 100755 --- a/.bin/git-rb-catchup +++ b/.bin/git-rb-catchup @@ -13,6 +13,8 @@ into smaller pieces, and be able to run tests to make sure things were still OK. """ import argparse +import os +from pathlib import Path import subprocess import sys from typing import List, Tuple, Union @@ -150,7 +152,10 @@ def main(argv: List[str]) -> int: parser = get_parser() opts = parser.parse_args(argv) - lbranch = get_local_branch() + try: + lbranch = get_local_branch() + except subprocess.CalledProcessError as e: + sys.exit(f'{os.path.basename(sys.argv[0])}: {Path.cwd()}:\n{e}\n{e.stderr.strip()}') print(f'Local branch resolved to "{lbranch}".') if not lbranch: print('Unable to resolve local branch', file=sys.stderr) -- 2.39.2