]> git.wh0rd.org Git - home.git/commitdiff
git-rb-catchup: handle running in non-git dirs better
authorMike Frysinger <vapier@gentoo.org>
Thu, 29 Apr 2021 21:07:15 +0000 (17:07 -0400)
committerMike Frysinger <vapier@gentoo.org>
Thu, 29 Apr 2021 21:07:15 +0000 (17:07 -0400)
.bin/git-rb-catchup

index 66b87a829ac2b61397f216d9be4c845d7dc6843d..cb34e137c99d5127a17f42efaceccd5b76e6c4b3 100755 (executable)
@@ -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)