From 27ec0352bc572f72d0fe180140fba0bef1d1591d Mon Sep 17 00:00:00 2001 From: Danil Akhtarov Date: Mon, 16 Dec 2024 22:56:51 +0400 Subject: [PATCH] chore: add a commit hash to the about dialog --- .github/scripts/version.py | 15 +++++++++++++++ .github/workflows/release.yml | 2 +- .gitignore | 1 + builder.py | 1 + languages/ru_RU/LC_MESSAGES/sportorg.po | 3 +++ pyproject.toml | 4 ++++ sportorg.iss | 2 +- sportorg/config.py | 12 ++++++++++++ sportorg/gui/dialogs/about.py | 12 +++++++++++- 9 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/scripts/version.py diff --git a/.github/scripts/version.py b/.github/scripts/version.py new file mode 100644 index 00000000..f2db1d30 --- /dev/null +++ b/.github/scripts/version.py @@ -0,0 +1,15 @@ +import subprocess +from pathlib import Path + + +def main() -> None: + res = subprocess.run( + ["git", "rev-parse", "HEAD"], + capture_output=True, + text=True, + ) + Path("version").write_text(res.stdout.strip(), encoding="utf-8") + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d318dfc..d8c72b7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: - name: Install python dependencies run: pip install poetry && poetry install -E win - name: Generate mo files - run: poetry run poe generate-mo + run: poetry run poe generate-mo generate-version - name: Build run: poetry run python builder.py build - name: Generate installer diff --git a/.gitignore b/.gitignore index d943c58c..ae7cec83 100644 --- a/.gitignore +++ b/.gitignore @@ -142,3 +142,4 @@ cython_debug/ data !tests/data +version \ No newline at end of file diff --git a/builder.py b/builder.py index bfcd29be..7afa30ba 100644 --- a/builder.py +++ b/builder.py @@ -18,6 +18,7 @@ config.base_dir("changelog_ru.md"), config.base_dir("configs"), config.STYLE_DIR, + config.COMMIT_VERSION_FILE, ] includes = ["atexit", "codecs", "playsound", "pyImpinj"] excludes = ["Tkinter", "unittest", "test", "pydoc"] diff --git a/languages/ru_RU/LC_MESSAGES/sportorg.po b/languages/ru_RU/LC_MESSAGES/sportorg.po index 6f8c780a..0ff801f1 100644 --- a/languages/ru_RU/LC_MESSAGES/sportorg.po +++ b/languages/ru_RU/LC_MESSAGES/sportorg.po @@ -21,6 +21,9 @@ msgstr "" msgid "About" msgstr "О нас" +msgid "Version" +msgstr "Версия" + msgid "Contributors" msgstr "Разработчики" diff --git a/pyproject.toml b/pyproject.toml index f210e570..d5f0a093 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,6 +93,10 @@ sequence = [ help = "Generate mo files" cmd = "python -m sportorg.language" +[tool.poe.tasks.generate-version] +help = "Generate version file" +cmd = "python .github/scripts/version.py" + [tool.poe.tasks.run] help = "Run" sequence = [ diff --git a/sportorg.iss b/sportorg.iss index 018f3d4c..d155e317 100644 --- a/sportorg.iss +++ b/sportorg.iss @@ -4,7 +4,7 @@ #define MyAppName "SportOrg" #define MyAppVersion "v1.7.1" #define MyVersionInfoVersion "1.7.1.0" -#define MyAppPublisher "Danil Akhtarov, Alexei Zhulev, Semyon Yakimov, Konstantin Bats, Sergei Kobelev" +#define MyAppPublisher "SportOrg Team" #define MyAppURL "https://sportorg.readthedocs.io" #define MyAppExeName "SportOrg.exe" diff --git a/sportorg/config.py b/sportorg/config.py index 6c87f851..53547df2 100644 --- a/sportorg/config.py +++ b/sportorg/config.py @@ -1,6 +1,7 @@ import logging.config import os import sys +from pathlib import Path from typing import Optional from pydantic import BaseSettings @@ -92,6 +93,17 @@ def style_dir(*paths) -> str: return os.path.join(STYLE_DIR, *paths) +COMMIT_VERSION_FILE = base_dir("version") + + +def commit_version() -> str: + path = Path(COMMIT_VERSION_FILE) + if not path.exists(): + return "" + + return path.read_text(encoding="utf-8") + + ICON = icon_dir("sportorg.svg") CONFIG_INI = data_dir("config.ini") diff --git a/sportorg/gui/dialogs/about.py b/sportorg/gui/dialogs/about.py index 48a470f7..2ee383be 100644 --- a/sportorg/gui/dialogs/about.py +++ b/sportorg/gui/dialogs/about.py @@ -39,6 +39,8 @@ def init_ui(self): ( "\t- Danil Akhtarov,\n" "\t- Sergei Kobelev,\n" + "\t- Alexander Karpov,\n" + "\t- Alexei Zhulev,\n" "\t- Semyon Yakimov,\n" "\t- Konstantin Bats." ), @@ -53,9 +55,17 @@ def init_ui(self): ) ) home_page_text.setOpenExternalLinks(True) - self.layout.addRow(home_page_text) + commit_version_text = QLabel() + commit_version_text.setTextInteractionFlags( + Qt.TextInteractionFlag.TextSelectableByMouse + ) + commit_version_text.setText( + "{}: {}".format(translate("Version"), config.commit_version()) + ) + self.layout.addRow(commit_version_text) + licence_title = QLabel() licence_title.setText("\nGPL v3 License") licence_title.setAlignment(Qt.AlignCenter)