feat: show git commit hash alongside the version

This commit is contained in:
imSp4rky
2026-07-30 13:44:07 -06:00
parent 42d7fd8303
commit 72b8ab7027
7 changed files with 97 additions and 6 deletions
+23
View File
@@ -1 +1,24 @@
import subprocess
from pathlib import Path
__version__ = "5.3.0"
def _git_commit() -> str:
root = Path(__file__).parents[2]
if not (root / ".git").exists():
return ""
try:
proc = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=root,
capture_output=True,
text=True,
timeout=2,
)
except (OSError, subprocess.SubprocessError):
return ""
return proc.stdout.strip() if proc.returncode == 0 else ""
__commit__ = _git_commit()
+3 -2
View File
@@ -10,7 +10,7 @@ from rich.padding import Padding
from rich.text import Text
from urllib3.exceptions import InsecureRequestWarning
from unshackle.core import __version__
from unshackle.core import __commit__, __version__
from unshackle.core.commands import Commands
from unshackle.core.config import config
from unshackle.core.console import ComfyRichHandler, console
@@ -63,7 +63,8 @@ def main(version: bool, debug: bool) -> None:
r" ▀▀▀ ▀▀ █▪ ▀▀▀▀ ▀▀▀ · ▀ ▀ ·▀▀▀ ·▀ ▀.▀▀▀ ▀▀▀ ",
style="ascii.art",
),
f"v [repr.number]{__version__}[/] - © 2025-{datetime.now().year} - github.com/unshackle-dl/unshackle",
f"v [repr.number]{__version__}[/]{f' ({__commit__})' if __commit__ else ''}"
f" - © 2025-{datetime.now().year} - github.com/unshackle-dl/unshackle",
),
(1, 11, 1, 10),
expand=True,
+8 -2
View File
@@ -8,7 +8,7 @@ import click
from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs, SwaggerInfo, SwaggerUiSettings
from unshackle.core import __version__
from unshackle.core import __commit__, __version__
from unshackle.core.api.errors import APIError, APIErrorCode, build_error_response, handle_api_exception
from unshackle.core.api.handlers import (
cancel_download_job_handler,
@@ -105,6 +105,10 @@ async def health(request: web.Request) -> web.Response:
version:
type: string
example: "2.0.0"
commit:
type: string
nullable: true
example: "a24c9b9"
update_check:
type: object
properties:
@@ -128,7 +132,9 @@ async def health(request: web.Request) -> web.Response:
log.warning(f"Failed to check for updates: {e}")
update_info = {"update_available": None, "current_version": __version__, "latest_version": None}
return web.json_response({"status": "ok", "version": __version__, "update_check": update_info})
return web.json_response(
{"status": "ok", "version": __version__, "commit": __commit__ or None, "update_check": update_info}
)
@api_handler
+2 -1
View File
@@ -787,7 +787,7 @@ class DebugLogger:
"""Log the start of a new session with environment information."""
import platform
from unshackle.core import __version__
from unshackle.core import __commit__, __version__
self.log(
level="INFO",
@@ -795,6 +795,7 @@ class DebugLogger:
message="Debug logging session started",
context={
"unshackle_version": __version__,
"unshackle_commit": __commit__ or None,
"python_version": sys.version,
"platform": platform.platform(),
"platform_system": platform.system(),