Skip to content

Commit

Permalink
version: make sure to get the git version from a virtme-ng git repo
Browse files Browse the repository at this point in the history
When we run git describe to append the git information to the version
string, make sure that the version.py module is contained in a virtme-ng
git repository, to avoid using information from any git repository in
any parent directory.

Reported-by: Matthieu Baerts (NGI0) <[email protected]>
Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
arighi committed Jul 14, 2024
1 parent 0ded79a commit 30d7c33
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions virtme_ng/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@

def get_version_string():
try:
# Get the version from git describe
# Get the version from `git describe`.
#
# Make sure to get the proper git repository by using the directory
# that contains this file and also make sure that the parent is a
# virtme-ng repository.
#
# Otherwise fallback to the static version defined in PKG_VERSION.
version = (
check_output(
"cd %s && git describe --always --long --dirty" % os.path.dirname(__file__),
"cd %s && [ -e ../.git ] && git describe --always --long --dirty" % os.path.dirname(__file__),
shell=True,
stderr=DEVNULL,
)
Expand Down

0 comments on commit 30d7c33

Please sign in to comment.