From b1156e45f3f5b154ff3555d2333010383a3b66ae Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 26 Dec 2025 15:01:25 +0100 Subject: [PATCH 1/6] reduce noise in docker --- src/backend/InvenTree/InvenTree/version.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/version.py b/src/backend/InvenTree/InvenTree/version.py index 387d60c0fb8b..f2fe39596d27 100644 --- a/src/backend/InvenTree/InvenTree/version.py +++ b/src/backend/InvenTree/InvenTree/version.py @@ -12,6 +12,8 @@ from datetime import datetime as dt from datetime import timedelta as td +from django.conf import settings + from .api_version import INVENTREE_API_TEXT, INVENTREE_API_VERSION # InvenTree software version @@ -22,6 +24,7 @@ logger = logging.getLogger('inventree') +warning_txt = 'INVE-W3: Could not detect git information.' # Discover git try: @@ -33,8 +36,11 @@ main_repo = Repo(pathlib.Path(__file__).parent.parent.parent.parent.parent) 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.') + # If we are running in a docker container, the repo may not be available, only logging as warning if not in docker + if settings.DOCKER: + logger.info(warning_txt) + else: + logger.warning(warning_txt) main_repo = None main_commit = None @@ -51,7 +57,7 @@ main_commit = None main_branch = None except Exception as exc: - logger.warning('INVE-W3: Could not detect git information.', exc_info=exc) + logger.warning(warning_txt, exc_info=exc) main_repo = None main_commit = None main_branch = None From 118b4c4b21e6d1e43d0985c6e80f14232a8def89 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 26 Dec 2025 16:33:40 +0100 Subject: [PATCH 2/6] refactor path infos --- tasks.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tasks.py b/tasks.py index 5eec35055346..58349ab314ec 100644 --- a/tasks.py +++ b/tasks.py @@ -357,6 +357,21 @@ def manage_py_path(): return manage_py_dir().joinpath('manage.py') +def _frontend_info(): + """Return the path of the frontend info directory.""" + return manage_py_dir().joinpath('web', 'static', 'web', '.vite') + + +def version_target_pth(): + """Return the path of the target version file.""" + return _frontend_info().joinpath('tag.txt') + + +def version_sha_pth(): + """Return the path of the SHA version file.""" + return _frontend_info().joinpath('sha.txt') + + # endregion if __name__ in ['__main__', 'tasks']: @@ -1788,13 +1803,9 @@ def check_already_current(tag=None, sha=None): ref = 'tag' if tag else 'commit' if tag: - current = manage_py_dir().joinpath( - 'web', 'static', 'web', '.vite', 'tag.txt' - ) + current = version_target_pth() elif sha: - current = manage_py_dir().joinpath( - 'web', 'static', 'web', '.vite', 'sha.txt' - ) + current = version_sha_pth() else: raise ValueError('Either tag or sha needs to be set') From 891ad83904970eee7044e5ca2702e8019a812327 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 26 Dec 2025 16:37:05 +0100 Subject: [PATCH 3/6] add more info during local frontend build --- tasks.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tasks.py b/tasks.py index 58349ab314ec..080e1b93b62c 100644 --- a/tasks.py +++ b/tasks.py @@ -1,5 +1,6 @@ """Tasks for automating certain actions and interacting with InvenTree from the CLI.""" +import datetime import json import os import pathlib @@ -372,6 +373,11 @@ def version_sha_pth(): return _frontend_info().joinpath('sha.txt') +def version_source_pth(): + """Return the path of the source version file.""" + return _frontend_info().joinpath('source.txt') + + # endregion if __name__ in ['__main__', 'tasks']: @@ -1679,6 +1685,31 @@ def frontend_build(c): info('Building frontend') yarn(c, 'yarn run build') + def write_info(path: Path, content: str): + """Helper function to write version content to file after cleaning it if it exists.""" + if path.exists(): + path.unlink() + path.write_text(content, encoding='utf-8') + + # Write version marker + try: + import src.backend.InvenTree.InvenTree.version as InvenTreeVersion + + if version_hash := InvenTreeVersion.inventreeCommitHash(): + write_info(version_sha_pth(), version_hash) + elif version_tag := InvenTreeVersion.inventreeVersion(): + write_info(version_target_pth(), version_tag) + else: + warning('No version information available to write frontend version marker') + + # Write source marker + write_info( + version_source_pth(), + f'local build on {datetime.datetime.now().isoformat()}', + ) + except Exception: + warning('Failed to write frontend version marker') + @task def frontend_server(c): From 2155587d361daf6fd83debf8fb73f521d291d196 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 26 Dec 2025 16:38:41 +0100 Subject: [PATCH 4/6] add frontend info during release build --- .github/workflows/release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 35f2aeea4442..3c738548b1cb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -65,6 +65,8 @@ jobs: run: cd src/backend/InvenTree/web/static/web/.vite && echo "${REF_NAME}" > tag.txt env: REF_NAME: ${{ github.ref_name }} + - name: Write version file - SOURCE + run: cd src/backend/InvenTree/web/static/web/.vite && echo "GitHub Actions build on $(date --utc +%Y-%m-%dT%H:%M:%SZ)" > source.txt - name: Zip frontend run: | cd src/backend/InvenTree/web/static/web From 43bc7d3790921f1ced1ef1ced6390583989c48eb Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 26 Dec 2025 17:15:33 +0100 Subject: [PATCH 5/6] ignore "special" import --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 080e1b93b62c..f849d7941e9b 100644 --- a/tasks.py +++ b/tasks.py @@ -1693,7 +1693,7 @@ def write_info(path: Path, content: str): # Write version marker try: - import src.backend.InvenTree.InvenTree.version as InvenTreeVersion + import src.backend.InvenTree.InvenTree.version as InvenTreeVersion # type: ignore[import] if version_hash := InvenTreeVersion.inventreeCommitHash(): write_info(version_sha_pth(), version_hash) From dfc70af06b33e7908a281f3a2195fca655726411 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Tue, 6 Jan 2026 15:09:09 +0100 Subject: [PATCH 6/6] change var name --- src/backend/InvenTree/InvenTree/version.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/version.py b/src/backend/InvenTree/InvenTree/version.py index f2fe39596d27..b28d86a433fc 100644 --- a/src/backend/InvenTree/InvenTree/version.py +++ b/src/backend/InvenTree/InvenTree/version.py @@ -24,7 +24,7 @@ logger = logging.getLogger('inventree') -warning_txt = 'INVE-W3: Could not detect git information.' +git_warning_txt = 'INVE-W3: Could not detect git information.' # Discover git try: @@ -38,9 +38,9 @@ except NotGitRepository: # If we are running in a docker container, the repo may not be available, only logging as warning if not in docker if settings.DOCKER: - logger.info(warning_txt) + logger.info(git_warning_txt) else: - logger.warning(warning_txt) + logger.warning(git_warning_txt) main_repo = None main_commit = None @@ -57,7 +57,7 @@ main_commit = None main_branch = None except Exception as exc: - logger.warning(warning_txt, exc_info=exc) + logger.warning(git_warning_txt, exc_info=exc) main_repo = None main_commit = None main_branch = None