aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/__init__.py5
-rw-r--r--pydis_site/context_processors.py8
-rw-r--r--pydis_site/settings.py6
-rw-r--r--pydis_site/templates/base/base.html1
-rw-r--r--pydis_site/templates/wiki/base.html1
5 files changed, 19 insertions, 2 deletions
diff --git a/pydis_site/__init__.py b/pydis_site/__init__.py
index df67cf71..f0702577 100644
--- a/pydis_site/__init__.py
+++ b/pydis_site/__init__.py
@@ -1,3 +1,4 @@
+import git
from wiki.plugins.macros.mdx import toc
# Remove the toc header prefix. There's no option for this, so we gotta monkey patch it.
@@ -7,3 +8,7 @@ toc.HEADER_ID_PREFIX = ''
# by a string because Allauth won't let us just give it a list _there_, we have to point
# at a list _somewhere else_ instead.
VALIDATORS = []
+
+# Git SHA
+repo = git.Repo(search_parent_directories=True)
+GIT_SHA = repo.head.object.hexsha
diff --git a/pydis_site/context_processors.py b/pydis_site/context_processors.py
new file mode 100644
index 00000000..bb66f21d
--- /dev/null
+++ b/pydis_site/context_processors.py
@@ -0,0 +1,8 @@
+from django.template import RequestContext
+
+from pydis_site import GIT_SHA
+
+
+def git_sha_processor(_: RequestContext) -> dict:
+ """Expose the git SHA for this repo to all views."""
+ return {'git_sha': GIT_SHA}
diff --git a/pydis_site/settings.py b/pydis_site/settings.py
index 2c87007c..ff2942f0 100644
--- a/pydis_site/settings.py
+++ b/pydis_site/settings.py
@@ -20,6 +20,7 @@ import sentry_sdk
from django.contrib.messages import constants as messages
from sentry_sdk.integrations.django import DjangoIntegration
+from pydis_site import GIT_SHA
if typing.TYPE_CHECKING:
from django.contrib.auth.models import User
@@ -33,7 +34,8 @@ env = environ.Env(
sentry_sdk.init(
dsn=env('SITE_SENTRY_DSN'),
integrations=[DjangoIntegration()],
- send_default_pii=True
+ send_default_pii=True,
+ release=f"pydis-site@{GIT_SHA}"
)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -157,8 +159,8 @@ TEMPLATES = [
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
-
"sekizai.context_processors.sekizai",
+ "pydis_site.context_processors.git_sha_processor"
],
},
},
diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html
index 4c70d778..70426dc1 100644
--- a/pydis_site/templates/base/base.html
+++ b/pydis_site/templates/base/base.html
@@ -37,6 +37,7 @@
{% render_block "css" %}
</head>
<body class="site">
+ <!-- Git hash for this release: {{ git_sha }} -->
<main class="site-content">
{% if messages %}
diff --git a/pydis_site/templates/wiki/base.html b/pydis_site/templates/wiki/base.html
index 846492ab..c9faf914 100644
--- a/pydis_site/templates/wiki/base.html
+++ b/pydis_site/templates/wiki/base.html
@@ -19,6 +19,7 @@
{% endblock %}
{% block content %}
+ <!-- Git hash for this release: {{ git_sha }} -->
{% block site_navbar %}
{% include "base/navbar.html" %}
{% endblock %}