From: Mike Frysinger Date: Thu, 29 Apr 2021 21:07:15 +0000 (-0400) Subject: git-rb-catchup: handle running in non-git dirs better X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=77ac61ce16ba016b713527ad337121817361acbd;p=home.git git-rb-catchup: handle running in non-git dirs better --- 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)