diff options
author | Ondřej Nový <ondrej.novy@firma.seznam.cz> | 2018-08-20 10:11:15 +0200 |
---|---|---|
committer | Ondřej Nový <ondrej.novy@firma.seznam.cz> | 2019-08-24 21:04:22 +0200 |
commit | a32fb30c16062ea64488e918077d635645e33e47 (patch) | |
tree | a22d94bf3c258dd1a4d963fd5753f663245902b2 /api-ref | |
parent | 2545372055922abd681ef665f9040590d2f5806c (diff) | |
download | swift-a32fb30c16062ea64488e918077d635645e33e47.tar.gz |
Use SOURCE_DATE_EPOCH in docs to make build reproducible
Set copyright year and html_last_updated_fmt to SOURCE_DATE_EPOCH if
it's set. See https://reproducible-builds.org/specs/source-date-epoch/
This patch make build reproducible, see https://reproducible-builds.org/
Change-Id: I730a8265ca2c70c639ef77a613908e84eb738b70
Diffstat (limited to 'api-ref')
-rw-r--r-- | api-ref/source/conf.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index 5d7f7f3ed..de1197b48 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -23,6 +23,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import datetime import os from swift import __version__ import subprocess @@ -154,20 +155,22 @@ pygments_style = 'sphinx' # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' -git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", - "-n1"] -try: - html_last_updated_fmt = subprocess.Popen( - git_cmd, stdout=subprocess.PIPE).communicate()[0] -except OSError: - warnings.warn('Cannot get last updated time from git repository. ' - 'Not setting "html_last_updated_fmt".') +if 'SOURCE_DATE_EPOCH' in os.environ: + now = float(os.environ.get('SOURCE_DATE_EPOCH')) + html_last_updated_fmt = datetime.datetime.utcfromtimestamp(now).isoformat() else: - if not isinstance(html_last_updated_fmt, str): - # for py3 - html_last_updated_fmt = html_last_updated_fmt.decode('ascii') - - + git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", + "-n1"] + try: + html_last_updated_fmt = subprocess.Popen( + git_cmd, stdout=subprocess.PIPE).communicate()[0] + except OSError: + warnings.warn('Cannot get last updated time from git repository. ' + 'Not setting "html_last_updated_fmt".') + else: + if not isinstance(html_last_updated_fmt, str): + # for py3 + html_last_updated_fmt = html_last_updated_fmt.decode('ascii') # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True |