[deploy] Add commit catpure to deploy step
This commit is contained in:
@ -12,6 +12,25 @@ def version_info(request):
|
||||
|
||||
commit = os.environ.get("VROBBLER_COMMIT")
|
||||
if not commit:
|
||||
# Try to import from _commit.py module first
|
||||
try:
|
||||
from vrobbler._commit import commit
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
return {"app_version": app_version, "git_commit": commit}
|
||||
|
||||
# Try to read from commit file (written during deploy)
|
||||
commit_file = Path("/var/lib/vrobbler/commit.txt")
|
||||
if commit_file.exists():
|
||||
try:
|
||||
commit = commit_file.read_text().strip()
|
||||
if commit:
|
||||
return {"app_version": app_version, "git_commit": commit}
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Fall back to git command
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
try:
|
||||
commit = (
|
||||
|
||||
Reference in New Issue
Block a user