aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/utils
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-08-22 02:49:28 +0200
committerGravatar Leon Sandøy <[email protected]>2020-08-22 02:49:28 +0200
commit416a0874187fdf96346e3f504d6542b3214957db (patch)
tree81cc9e528566cea23420979edb588d162bb5626f /pydis_site/utils
parentWe need .git in the docker container for the SHA. (diff)
Move git SHA fetcher into utils.
Diffstat (limited to 'pydis_site/utils')
-rw-r--r--pydis_site/utils/resources.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/pydis_site/utils/resources.py b/pydis_site/utils/resources.py
index 637fd785..d36c4b77 100644
--- a/pydis_site/utils/resources.py
+++ b/pydis_site/utils/resources.py
@@ -4,8 +4,13 @@ import glob
import typing
from dataclasses import dataclass
+import git
import yaml
+# Git SHA
+repo = git.Repo(search_parent_directories=True)
+GIT_SHA = repo.head.object.hexsha
+
@dataclass
class URL:
@@ -89,3 +94,8 @@ def load_categories(order: typing.List[str]) -> typing.List[Category]:
categories.append(Category.construct_from_directory(direc))
return categories
+
+
+def get_git_sha() -> str:
+ """Get the Git SHA for this repo."""
+ return GIT_SHA