blob: 940858c25e3f2ebe0034f00813ab479c3c9c2d48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# SPDX-FileCopyrightText: 2023 Agathe Porte
#
# SPDX-License-Identifier: MIT
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)
|