launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20665
[Merge] lp:~cjwatson/launchpad/revision-header into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/revision-header into lp:launchpad.
Commit message:
Publish Launchpad's code revision in an X-Revision header.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/revision-header/+merge/298124
Publish Launchpad's code revision in an X-Revision header.
This means that lp-devops-dashboard will no longer need to do this kind of thing to scrape out the revno, and can just do a simple HEAD request instead:
lp_version_comment = soup.find(
text=re.compile("external actions issued in"))
revision_re = re.compile(r'r(\d+)')
matches = revision_re.search(lp_version_comment)
if matches:
self.last_deployed_revno = int(matches.group(1))
Once we move to git, the value can switch to being the commit ID.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/revision-header into lp:launchpad.
=== modified file 'lib/lp/services/webapp/servers.py'
--- lib/lp/services/webapp/servers.py 2016-03-03 19:16:36 +0000
+++ lib/lp/services/webapp/servers.py 2016-06-22 14:38:25 +0000
@@ -60,6 +60,7 @@
from zope.server.http.wsgihttpserver import PMDBWSGIHTTPServer
from zope.session.interfaces import ISession
+from lp.app import versioninfo
from lp.app.errors import UnexpectedFormData
import lp.layers
from lp.services.config import config
@@ -600,6 +601,9 @@
self.response.setHeader(
'Strict-Transport-Security', 'max-age=15552000')
+ # Publish revision information.
+ self.response.setHeader('X-Revision', versioninfo.revno)
+
@property
def stepstogo(self):
return StepsToGo(self)
=== modified file 'lib/lp/services/webapp/tests/test_servers.py'
--- lib/lp/services/webapp/tests/test_servers.py 2015-07-08 16:05:11 +0000
+++ lib/lp/services/webapp/tests/test_servers.py 2016-06-22 14:38:25 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -30,6 +30,7 @@
Interface,
)
+from lp.app import versioninfo
from lp.services.webapp.interfaces import IFinishReadOnlyRequestEvent
from lp.services.webapp.publication import LaunchpadBrowserPublication
from lp.services.webapp.servers import (
@@ -382,6 +383,10 @@
response.getHeader(
'Strict-Transport-Security'), 'max-age=15552000')
+ def test_baserequest_revision_header(self):
+ response = LaunchpadBrowserRequest(StringIO.StringIO(''), {}).response
+ self.assertEqual(versioninfo.revno, response.getHeader('X-Revision'))
+
def test_baserequest_recovers_from_bad_path_info_encoding(self):
# The request object recodes PATH_INFO to ensure sane_environment
# does not raise a UnicodeDecodeError when LaunchpadBrowserRequest
Follow ups