2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

fix(backend): reduce noice in docker image start (#9515)

make dulwich detection less loud
This commit is contained in:
Matthias Mair 2025-04-15 23:21:48 +02:00 committed by GitHub
parent 5e7e258289
commit 4c830fb167
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,13 +26,21 @@ logger = logging.getLogger('inventree')
# Discover git # Discover git
try: try:
from dulwich.errors import NotGitRepository
from dulwich.porcelain import active_branch from dulwich.porcelain import active_branch
from dulwich.repo import Repo from dulwich.repo import Repo
try:
main_repo = Repo(pathlib.Path(__file__).parent.parent.parent.parent.parent) main_repo = Repo(pathlib.Path(__file__).parent.parent.parent.parent.parent)
main_commit = main_repo[main_repo.head()] main_commit = main_repo[main_repo.head()]
except NotGitRepository:
# If we are running in a docker container, the repo may not be available
logger.warning('INVE-W3: Could not detect git information.')
main_repo = None
main_commit = None
try: try:
main_branch = active_branch(main_repo) main_branch = active_branch(main_repo) if main_repo else None
except (KeyError, IndexError): except (KeyError, IndexError):
logger.warning('INVE-W1: Current branch could not be detected.') logger.warning('INVE-W1: Current branch could not be detected.')
main_branch = None main_branch = None