mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Reuse get_last_commit_hash
Noticed that hash wasn't updating from live git repo because of this. Also update commit data only when running the package, not extension.
This commit is contained in:
@@ -28,6 +28,10 @@ IN_BLENDER = sys.modules.get("bpy", None)
|
|||||||
if IN_BLENDER:
|
if IN_BLENDER:
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
# This file is executed twice - first as a bonsai-extension
|
||||||
|
# and then as a bonsai-package.
|
||||||
|
IN_PACKAGE = __package__ == "bonsai"
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import platform
|
import platform
|
||||||
import traceback
|
import traceback
|
||||||
@@ -218,17 +222,21 @@ if IN_BLENDER:
|
|||||||
info["binary_python_version"] = version
|
info["binary_python_version"] = version
|
||||||
return info
|
return info
|
||||||
|
|
||||||
try:
|
def update_commit_data() -> None:
|
||||||
import git
|
try:
|
||||||
|
import git
|
||||||
|
|
||||||
# We can't just use __file__ as bonsai/__init__.py is typically not symlinked
|
global last_commit_hash
|
||||||
# as Blender have errors symlinking main addon package file.
|
global last_commit_date
|
||||||
path = Path(__file__).resolve().parent
|
path = Path(__file__).resolve().parent
|
||||||
repo = git.Repo(str(path), search_parent_directories=True)
|
repo = git.Repo(str(path), search_parent_directories=True)
|
||||||
last_commit_hash = repo.head.object.hexsha
|
last_commit_hash = repo.head.object.hexsha
|
||||||
last_commit_date = repo.head.object.committed_datetime.isoformat()
|
last_commit_date = repo.head.object.committed_datetime.isoformat()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if IN_PACKAGE:
|
||||||
|
update_commit_data()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ifcopenshell.api
|
import ifcopenshell.api
|
||||||
|
|||||||
@@ -1243,16 +1243,7 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_last_commit_hash(cls) -> Union[str, None]:
|
def get_last_commit_hash(cls) -> Union[str, None]:
|
||||||
"""Get 8 symbols of last commit hash if it's present or return None otherwise."""
|
return bonsai.get_last_commit_hash()
|
||||||
bbim = cls.get_bbim_extension_package()
|
|
||||||
commit_hash = bbim.last_commit_hash
|
|
||||||
|
|
||||||
# Commit hash is unset - user is using __init__ from repo
|
|
||||||
# without setting up git repository.
|
|
||||||
if commit_hash == "8888888":
|
|
||||||
return None
|
|
||||||
|
|
||||||
return commit_hash[:7]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_bonsai_version(cls) -> str:
|
def get_bonsai_version(cls) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user