Skip to content

Display git commit info on About page#32

Merged
jonocodes merged 4 commits intomainfrom
claude/add-git-info-deployment-TT9WW
Feb 22, 2026
Merged

Display git commit info on About page#32
jonocodes merged 4 commits intomainfrom
claude/add-git-info-deployment-TT9WW

Conversation

@jonocodes
Copy link
Owner

Summary

Added functionality to capture and display git repository information (commit SHA, branch, and commit message) on the About page in the admin preferences view.

Key Changes

  • Added _get_git_info() function in media/apps.py that captures git metadata at application startup:
    • Full and short commit SHA
    • Current branch name
    • Latest commit message
    • Gracefully handles cases where git is unavailable
  • Exported GIT_INFO constant from media/apps.py for use in views
  • Updated preferences_view() in media/views.py to pass git info to the template context
  • Enhanced media/templates/admin/preferences.html to display git information alongside the deployment time:
    • Shows short commit SHA as a clickable link to GitHub
    • Displays commit message as link tooltip
    • Shows current branch name when available
    • Only displays git info section if commit SHA is available

Implementation Details

  • Git commands are executed at Django app startup to minimize runtime overhead
  • All git subprocess calls suppress stderr and handle exceptions gracefully to prevent deployment failures if git is unavailable
  • The commit SHA is linked directly to the GitHub repository for easy reference

https://claude.ai/code/session_016jtUbw7EGXX2hxDvvgBgQ8

@jonocodes jonocodes force-pushed the claude/add-git-info-deployment-TT9WW branch from 54d77a6 to c9a60f7 Compare February 22, 2026 14:03
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
Use a multi-stage Docker build to extract git info at build time:
- Stage 1 (alpine + git + jq) reads .git and writes /git_info.json
- Stage 2 copies the JSON to /etc/git_info.json (survives volume mounts)
- apps.py checks /etc/git_info.json first, then falls back to live git

Also un-ignores .git in .dockerignore so the first build stage can
access it, and adds git_info.json to .gitignore.

https://claude.ai/code/session_016jtUbw7EGXX2hxDvvgBgQ8
Prints the commit SHA, branch, and commit message to the server log
when the Django app starts, making it easy to identify which version
is running.

https://claude.ai/code/session_016jtUbw7EGXX2hxDvvgBgQ8
Coolify doesn't include .git in the build context, causing
"/.git: not found" during docker build. Replace the multi-stage
git-info approach with build args (GIT_COMMIT_SHA, GIT_COMMIT_MSG,
GIT_BRANCH) and add .git to .dockerignore since it's no longer needed.

https://claude.ai/code/session_016jtUbw7EGXX2hxDvvgBgQ8
@jonocodes jonocodes force-pushed the claude/add-git-info-deployment-TT9WW branch from 325e315 to d10467d Compare February 22, 2026 16:42
@jonocodes jonocodes merged commit 834d02c into main Feb 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants