From 21725faf3eb1d28f137c9c30a0139f3f794b634e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 05:54:21 +0000 Subject: [PATCH 1/4] Show git commit SHA and branch next to deployment time on About page Captures git info (commit SHA, branch, commit message) at app startup and displays it alongside the deployment time in the preferences/about page. The commit SHA links to the GitHub commit page and hovering shows the commit message. https://claude.ai/code/session_016jtUbw7EGXX2hxDvvgBgQ8 --- media/apps.py | 24 ++++++++++++++++++++++++ media/templates/admin/preferences.html | 9 +++++++++ media/views.py | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/media/apps.py b/media/apps.py index acab66c..0883817 100644 --- a/media/apps.py +++ b/media/apps.py @@ -1,3 +1,5 @@ +import subprocess + from django.apps import AppConfig from django.utils import timezone @@ -5,6 +7,28 @@ DEPLOY_TIME = timezone.now() +def _get_git_info(): + """Capture git info at startup for display on the About page.""" + info = {'commit_sha': '', 'commit_sha_short': '', 'commit_message': '', 'branch': ''} + try: + info['commit_sha'] = subprocess.check_output( + ['git', 'rev-parse', 'HEAD'], stderr=subprocess.DEVNULL, text=True + ).strip() + info['commit_sha_short'] = info['commit_sha'][:7] + info['commit_message'] = subprocess.check_output( + ['git', 'log', '-1', '--pretty=%s'], stderr=subprocess.DEVNULL, text=True + ).strip() + info['branch'] = subprocess.check_output( + ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stderr=subprocess.DEVNULL, text=True + ).strip() + except Exception: + pass + return info + + +GIT_INFO = _get_git_info() + + class MediaConfig(AppConfig): name = 'media' default_auto_field = 'django.db.models.BigAutoField' diff --git a/media/templates/admin/preferences.html b/media/templates/admin/preferences.html index 5eca12f..bdabeec 100644 --- a/media/templates/admin/preferences.html +++ b/media/templates/admin/preferences.html @@ -244,6 +244,15 @@

{% trans "About" %}

{{ deploy_time|timesince }} {% trans "ago" %} ({{ deploy_time }}) + {% if git_info.commit_sha_short %} + — + + {{ git_info.commit_sha_short }} + + {% if git_info.branch %} + on {{ git_info.branch }} + {% endif %} + {% endif %}