display current commit in status bar

it works for users who symlinked their blenderbim/bim folders to git repository or installed blenderbim from release created from makefile
https://i.imgur.com/mEBH9I7.png
This commit is contained in:
Andrej730
2023-07-12 12:15:12 +05:00
parent 3813c26db7
commit dd0a015ec3
3 changed files with 17 additions and 1 deletions
+2
View File
@@ -36,6 +36,7 @@ endif
endif
VERSION:=`date '+%y%m%d'`
LAST_COMMIT_HASH:=$(git rev-parse HEAD)
PYVERSION:=py310
ifeq ($(PYVERSION), py39)
@@ -675,6 +676,7 @@ endif
rm -rf dist/blenderbim/libs/site/packages/numpy.libs
cd dist/blenderbim && $(SED) "s/999999/$(VERSION)/" __init__.py
cd dist/blenderbim/bim && $(SED) "s/8888888/$(LAST_COMMIT_HASH)/" __init__.py
cd dist && zip -r blenderbim-$(VERSION)-$(PYVERSION)-$(PLATFORM).zip ./*
rm -rf dist/blenderbim
+10
View File
@@ -17,6 +17,7 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import os
from pathlib import Path
import bpy
import bpy.utils.previews
import blenderbim
@@ -150,6 +151,7 @@ for mod in modules.values():
addon_keymaps = []
icons = None
is_registering = False
last_commit_hash = "8888888"
def on_register(scene):
@@ -209,6 +211,14 @@ def register():
icons = icon_preview
global last_commit_hash
try:
import git
path = Path(__file__).resolve().parent
repo = git.Repo(str(path), search_parent_directories=True)
last_commit_hash = repo.head.object.hexsha
except:
pass
def unregister():
global icons
+5 -1
View File
@@ -30,6 +30,7 @@ from ifcopenshell.util.doc import (
)
from . import ifc
import blenderbim.tool as tool
import blenderbim.bim
from blenderbim.bim.helper import IfcHeaderExtractor
from blenderbim.bim.prop import Attribute
@@ -542,7 +543,10 @@ class UIData:
def draw_statusbar(self, context):
if not UIData.is_loaded:
UIData.load()
self.layout.label(text=f"BlenderBIM Add-on v{UIData.data['version']}")
text = f"BlenderBIM Add-on v{UIData.data['version']}"
if blenderbim.bim.last_commit_hash != "8888888":
text += f"@{blenderbim.bim.last_commit_hash[:7]}"
self.layout.label(text=text)
def draw_custom_context_menu(self, context):