From 32451a15ecb6b4bb42a2b77d5125eeb1163beea2 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Tue, 10 Mar 2020 11:12:58 +0100 Subject: [PATCH] pick-ui: make .pick_status.json path relative to the git root instead of the script This allows the script to be called from another git worktree for instance, which I need for my workflow :) Signed-off-by: Eric Engestrom Reviewed-by: Dylan Baker Part-of: --- bin/pick/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/pick/core.py b/bin/pick/core.py index dbfce46c36f..9b8926224b8 100644 --- a/bin/pick/core.py +++ b/bin/pick/core.py @@ -25,6 +25,7 @@ import enum import json import pathlib import re +import subprocess import typing import attr @@ -55,7 +56,9 @@ SEM = asyncio.Semaphore(50) COMMIT_LOCK = asyncio.Lock() -pick_status_json = pathlib.Path(__file__).parent.parent.parent / '.pick_status.json' +git_toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'], + stderr=subprocess.DEVNULL).decode("ascii").strip() +pick_status_json = pathlib.Path(git_toplevel) / '.pick_status.json' class PickUIException(Exception): -- 2.30.2