version.py: fix build_id after recent refactors (#1393)

* version.py: fix build_id after recent refactors

* fix lint
This commit is contained in:
Disconnect3d 2022-11-27 23:11:04 +07:00 committed by GitHub
parent 39ebd66539
commit f01f932755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -6,8 +6,11 @@ def build_id(): # type: () -> str
"""
Returns pwndbg commit id if git is available.
"""
pwndbg_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
assert os.path.exists(os.path.join(pwndbg_dir, "gdbinit.py"))
try:
git_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".git")
git_path = os.path.join(pwndbg_dir, ".git")
cmd = ["git", "--git-dir", git_path, "rev-parse", "--short", "HEAD"]
commit_id = subprocess.check_output(cmd, stderr=subprocess.STDOUT)