summaryrefslogtreecommitdiffstats
path: root/git_describe.py
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2020-06-14 08:43:05 +0200
committerAgathe Porte <microjoe@microjoe.org>2020-06-14 08:43:05 +0200
commit813a5be1be6483b92292135c1e999a8263d1b9d4 (patch)
tree3bb15dde4181acdff516078d38c2f9ddf7680dc3 /git_describe.py
parentc9807e45d86ef872c236172cacb4218364911a48 (diff)
downloadpelican-git-describe-813a5be1be6483b92292135c1e999a8263d1b9d4.tar.gz
pelican-git-describe-813a5be1be6483b92292135c1e999a8263d1b9d4.zip
total revamp
Diffstat (limited to 'git_describe.py')
-rw-r--r--git_describe.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/git_describe.py b/git_describe.py
new file mode 100644
index 0000000..d33cc0b
--- /dev/null
+++ b/git_describe.py
@@ -0,0 +1,22 @@
+import subprocess
+
+from pelican import signals
+
+
+def git_describe():
+ """Check and return git describe --tags value."""
+ return subprocess \
+ .run(["git", "describe", "--tags"],
+ stdout=subprocess.PIPE, check=True) \
+ .stdout.decode('utf-8').strip()
+
+
+def expand_context(generators):
+ desc = git_describe()
+ for gen in generators:
+ gen.context['git_describe'] = desc
+
+
+def register():
+ """Register Pelican signals to dedicated functions."""
+ signals.all_generators_finalized.connect(expand_context)