Skip to content

Commit 1fea0f5

Browse files
committed
Fix doc build if git is absent
When building packages if git is absent, then we should not set html_last_updated_fmt. It can still be set via the -D switch when building with sphinx-build. Change-Id: I992f38ba935536c59217e22d4071f40a69090fc2 Closes-Bug: #1552251
1 parent 8e7940a commit 1fea0f5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

doc/source/conf.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import subprocess
1515
import sys
1616
import os
17+
import warnings
1718

1819
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
1920
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
@@ -150,10 +151,15 @@
150151
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
151152
# using the given strftime format.
152153
#html_last_updated_fmt = '%b %d, %Y'
153-
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
154-
"-n1"]
155-
html_last_updated_fmt = subprocess.Popen(
156-
git_cmd, stdout=subprocess.PIPE).communicate()[0]
154+
try:
155+
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
156+
"-n1"]
157+
html_last_updated_fmt = subprocess.Popen(
158+
git_cmd, stdout=subprocess.PIPE).communicate()[0]
159+
except Exception:
160+
warnings.warn('Cannot get last updated time from git repository. '
161+
'Not setting "html_last_updated_fmt".')
162+
157163

158164
# If true, SmartyPants will be used to convert quotes and dashes to
159165
# typographically correct entities.

0 commit comments

Comments
 (0)