pick-ui: make .pick_status.json path relative to the git root instead of the script
authorEric Engestrom <eric@engestrom.ch>
Tue, 10 Mar 2020 10:12:58 +0000 (11:12 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Apr 2020 01:13:53 +0000 (01:13 +0000)
This allows the script to be called from another git worktree for instance,
which I need for my workflow :)

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4649>

bin/pick/core.py

index dbfce46c36f0d3d8c3a85daf0060bba60aac76f3..9b8926224b809876db718ba265e1be8113ffcbba 100644 (file)
@@ -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):