Skip to content

Commit

Permalink
version: run git describe from the path of the python file
Browse files Browse the repository at this point in the history
When we append the git information to the version string we can't simply
run git describe from any location, or we may end up getting the version
of another git repository (like the kernel).

To prevent this, always run `git describe` from the path where
version.py is located: installed vesions will return the plain version
as before, while running `vng --version` directly from the git repo will
return the version with the additional git information.

Fixes: 5cdb2f0 ("version: generate verison string based on git information")
Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
arighi committed Jul 14, 2024
1 parent 22fb61a commit 0ded79a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion virtme_ng/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""virtme-ng version"""

import os
from subprocess import check_output, DEVNULL, CalledProcessError

PKG_VERSION = "1.25"
Expand All @@ -13,7 +14,7 @@ def get_version_string():
# Get the version from git describe
version = (
check_output(
"git describe --always --long --dirty",
"cd %s && git describe --always --long --dirty" % os.path.dirname(__file__),
shell=True,
stderr=DEVNULL,
)
Expand Down

0 comments on commit 0ded79a

Please sign in to comment.