From: Oto Šťáva Date: Thu, 3 Nov 2022 07:16:16 +0000 (+0100) Subject: doc/conf.py: fetch copyright year from git commit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23a6000229924e5cf76a562810838f738a78e357;p=thirdparty%2Fknot-resolver.git doc/conf.py: fetch copyright year from git commit Using Git commit to avoid problems with reproducible builds; with fallback to system time in case Git is not available for whatever reason. --- diff --git a/doc/conf.py b/doc/conf.py index 05e0d8de9..ab7e6db2e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,6 +4,7 @@ import os import re import subprocess +from datetime import date import sphinx_rtd_theme @@ -24,9 +25,20 @@ breathe_domain_by_extension = {"h": "c"} source_suffix = '.rst' master_doc = 'index' +# Get current year (preferably from Git commit) +commit_year = date.today().year + +try: + commit_date_str = subprocess.check_output(['git', 'show', '--no-patch', '--format=%cs'])\ + .decode().strip() + commit_date = date.fromisoformat(commit_date_str) + commit_year = commit_date.year +except BaseException as e: + print('Could not get current commit, using system time for copyright:', e) + # General information about the project. project = u'Knot Resolver' -copyright = u'2014-2020 CZ.NIC labs' +copyright = u'2014-{current} CZ.NIC labs'.format(current=commit_year) with open('../meson.build') as f: for line in f: match = re.match(r"\s*version\s*:\s*'([^']+)'.*", line)