diff options
| author | Brett Curran <brettjcurran@gmail.com> | 2026-02-14 23:07:25 +1100 |
|---|---|---|
| committer | Brett Curran <brettjcurran@gmail.com> | 2026-04-15 16:37:51 +1000 |
| commit | b0b26420807f094b860ae3996d4c62261bc732cc (patch) | |
| tree | 3f79984ffa187dafde4ef0f6fe11f7645e741057 | |
| parent | 024f674136bf56b36d4565ea4541a1a15b14898d (diff) | |
refactor get_git_version() to get_app_version()
* now gets current version of installed app on the system, or the current git version if metadata cannot be found
| -rw-r--r-- | src/vtt_publish/tui.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/vtt_publish/tui.py b/src/vtt_publish/tui.py index 05665e0..d33ec26 100644 --- a/src/vtt_publish/tui.py +++ b/src/vtt_publish/tui.py @@ -8,6 +8,7 @@ import os import subprocess import json import time +from importlib.metadata import version, PackageNotFoundError HISTORY_FILE = ".publish_history.json" @@ -226,7 +227,7 @@ class PublisherApp(App): #log_pane { height: 20%; - border-top: solid #4caf50; + border: solid #4caf50; background: #0a1410; color: #81c784; text-wrap: wrap; @@ -241,7 +242,12 @@ class PublisherApp(App): ("q", "quit", "Quit"), ] - def get_git_version(self): + def get_app_version(self): + try: + return version("vtt-publish") + except PackageNotFoundError: + pass + try: # git describe --tags --always --dirty # Returns things like: "v1.0.2-4-g9a2b3c" or "v1.0.2" @@ -295,7 +301,7 @@ class PublisherApp(App): def on_mount(self) -> None: """Called when app starts.""" - version_str = self.get_git_version() + version_str = self.get_app_version() self.title = f"FVTT PUBLISH {version_str}" self.show_synced_files = True @@ -310,8 +316,6 @@ class PublisherApp(App): table.add_column("Filename", key="Filename") table.add_column("Location", key="Location") - self.log_message("System initialized.") - def is_ignored(self, path: Path) -> bool: """Check if path contains any ignored patterns.""" path_str = str(path).lower() @@ -440,8 +444,6 @@ class PublisherApp(App): cmd = ["rsync", "-avz", str(full_path), destination] try: - self.log_message(f"Run: {' '.join(cmd)}") # Debug print - result = subprocess.run( cmd, capture_output=True, |
