Skip to content

Commit

Permalink
moved version.py to lib/
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh93 committed Sep 5, 2022
1 parent 720e49f commit 4b78444
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pwndbg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import pwndbg.gdblib.typeinfo
import pwndbg.gdbutils.functions
import pwndbg.heap
import pwndbg.lib.version
import pwndbg.memory
import pwndbg.net
import pwndbg.proc
Expand All @@ -79,13 +80,12 @@
import pwndbg.stack
import pwndbg.tls
import pwndbg.ui
import pwndbg.version
import pwndbg.vmmap
import pwndbg.wrappers
import pwndbg.wrappers.checksec
import pwndbg.wrappers.readelf

__version__ = pwndbg.version.__version__
__version__ = pwndbg.lib.version.__version__
version = __version__

try:
Expand Down
28 changes: 28 additions & 0 deletions pwndbg/lib/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import subprocess


def build_id():
"""
Returns pwndbg commit id if git is available.
"""
try:
git_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".git")
cmd = ["git", "--git-dir", git_path, "rev-parse", "--short", "HEAD"]

commit_id = subprocess.check_output(cmd, stderr=subprocess.STDOUT)

return "build: %s" % commit_id.decode("utf-8").strip("\n")

except (OSError, subprocess.CalledProcessError):
# OSError -> no git in $PATH
# CalledProcessError -> git return code != 0
return ""


__version__ = "1.1.0"

b_id = build_id()

if b_id:
__version__ += " %s" % b_id

0 comments on commit 4b78444

Please sign in to comment.