From 6fc1f09aed23f230da2b889efe015773fd57eaee Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Thu, 6 Jun 2019 13:04:03 +0200 Subject: [PATCH] [core] Add git branch name in version name During development the git branch will be added to the version name. In releases, as there is no git repository included, the __version__ will not be modified. --- meshroom/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meshroom/__init__.py b/meshroom/__init__.py index 8ee42b3c..d91e3c17 100644 --- a/meshroom/__init__.py +++ b/meshroom/__init__.py @@ -1,6 +1,17 @@ __version__ = "2019.1.0" import os +scriptPath = os.path.dirname(os.path.abspath( __file__ )) +headFilepath = os.path.join(scriptPath, "../.git/HEAD") +# If we are in a release, the git history will not exist. +# If we are in development, we declare the name of the git development branch in the version name +if os.path.exists(headFilepath): + with open (headFilepath, "r") as headFile: + data = headFile.readlines() + branchName = data[0].split('/')[-1] + # Add git branch name to the Meshroom version name + __version__ = __version__ + "-" + branchName + # Allow override from env variable __version__ = os.environ.get("REZ_MESHROOM_VERSION", __version__)