aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-08-22 03:54:51 +0200
committerGravatar Leon Sandøy <[email protected]>2020-08-22 03:54:51 +0200
commita71c38f07bba0191ba28eef12eea56e8a9265349 (patch)
tree1bea924a12c27854cbe0b4dd11ef5a0bf30472b1
parentRemove the SHA from the wiki base.html (diff)
Move the SHA into constants.py.
The util was redundant. Thanks @MarkKoz
-rw-r--r--pydis_site/constants.py (renamed from pydis_site/utils/utils.py)5
-rw-r--r--pydis_site/context_processors.py4
-rw-r--r--pydis_site/settings.py4
-rw-r--r--pydis_site/tests/test_utils.py11
-rw-r--r--pydis_site/utils/__init__.py3
5 files changed, 4 insertions, 23 deletions
diff --git a/pydis_site/utils/utils.py b/pydis_site/constants.py
index 2033ea19..0b76694a 100644
--- a/pydis_site/utils/utils.py
+++ b/pydis_site/constants.py
@@ -3,8 +3,3 @@ import git
# Git SHA
repo = git.Repo(search_parent_directories=True)
GIT_SHA = repo.head.object.hexsha
-
-
-def get_git_sha() -> str:
- """Get the Git SHA for this repo."""
- return GIT_SHA
diff --git a/pydis_site/context_processors.py b/pydis_site/context_processors.py
index ab5a4168..6937a3db 100644
--- a/pydis_site/context_processors.py
+++ b/pydis_site/context_processors.py
@@ -1,8 +1,8 @@
from django.template import RequestContext
-from pydis_site.utils import get_git_sha
+from pydis_site.constants import GIT_SHA
def git_sha_processor(_: RequestContext) -> dict:
"""Expose the git SHA for this repo to all views."""
- return {'git_sha': get_git_sha()}
+ return {'git_sha': GIT_SHA}
diff --git a/pydis_site/settings.py b/pydis_site/settings.py
index 0a5b0eed..1f042c1b 100644
--- a/pydis_site/settings.py
+++ b/pydis_site/settings.py
@@ -20,7 +20,7 @@ import sentry_sdk
from django.contrib.messages import constants as messages
from sentry_sdk.integrations.django import DjangoIntegration
-from pydis_site.utils import get_git_sha
+from pydis_site.constants import GIT_SHA
if typing.TYPE_CHECKING:
from django.contrib.auth.models import User
@@ -35,7 +35,7 @@ sentry_sdk.init(
dsn=env('SITE_SENTRY_DSN'),
integrations=[DjangoIntegration()],
send_default_pii=True,
- release=f"pydis-site@{get_git_sha()}"
+ release=f"pydis-site@{GIT_SHA}"
)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
diff --git a/pydis_site/tests/test_utils.py b/pydis_site/tests/test_utils.py
deleted file mode 100644
index f1419860..00000000
--- a/pydis_site/tests/test_utils.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from django.test import TestCase
-
-from pydis_site.utils import get_git_sha
-from pydis_site.utils.utils import GIT_SHA
-
-
-class UtilsTests(TestCase):
-
- def test_git_sha(self):
- """Test that the get_git_sha returns the correct SHA."""
- self.assertEqual(get_git_sha(), GIT_SHA)
diff --git a/pydis_site/utils/__init__.py b/pydis_site/utils/__init__.py
deleted file mode 100644
index bb91b3d8..00000000
--- a/pydis_site/utils/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from .utils import get_git_sha
-
-__all__ = ['get_git_sha']