← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:apidoc-without-git into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:apidoc-without-git into launchpad:master.

Commit message:
Make apidoc generation work outside a git working tree

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/442017

Our machine-readable API documentation files are generated using the time of the last commit as their file modification times, in order that `ETag` headers are consistent.  However, when building API documentation in a charmed deployment, we don't have a git working tree.  Pick up the timestamp from `version-info.py` instead.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:apidoc-without-git into launchpad:master.
diff --git a/utilities/create-lp-wadl-and-apidoc.py b/utilities/create-lp-wadl-and-apidoc.py
index 216db32..0192d3a 100755
--- a/utilities/create-lp-wadl-and-apidoc.py
+++ b/utilities/create-lp-wadl-and-apidoc.py
@@ -15,8 +15,8 @@ import _pythonpath  # noqa: F401
 
 import optparse
 import os
-import subprocess
 import sys
+from datetime import datetime
 from multiprocessing import Process
 
 import six
@@ -24,6 +24,7 @@ from lazr.restful.interfaces import IWebServiceConfiguration
 from zope.component import getUtility
 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
 
+from lp.app import versioninfo
 from lp.services.scripts import execute_zcml_for_scripts
 from lp.services.webservice.wadl import (
     generate_html,
@@ -140,10 +141,7 @@ def main(directory, force=False):
     # generated files so that we can safely use it as part of Apache's etag
     # generation in the face of multiple servers/filesystems.
     timestamp = int(
-        subprocess.check_output(
-            ["git", "log", "-1", "--format=%ct", "HEAD"],
-            universal_newlines=True,
-        )
+        datetime.strptime(versioninfo.date, "%Y-%m-%d %H:%M:%S %z").timestamp()
     )
 
     # Start a process to build each set of WADL and HTML files.