← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:add-revision-header-to-loggerhead into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:add-revision-header-to-loggerhead into launchpad:master.

Commit message:
Add the launchpad revision header to loggerhead responses

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This makes it a bit nicer for debugging which revision we're actually using.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:add-revision-header-to-loggerhead into launchpad:master.
diff --git a/lib/launchpad_loggerhead/session.py b/lib/launchpad_loggerhead/session.py
index cf4516b..3792487 100644
--- a/lib/launchpad_loggerhead/session.py
+++ b/lib/launchpad_loggerhead/session.py
@@ -8,6 +8,8 @@ import pickle
 
 from paste.auth.cookie import AuthCookieHandler
 
+from lp.app import versioninfo
+
 
 class SessionHandler(object):
     """Middleware that provides a cookie-based session.
@@ -62,5 +64,7 @@ class SessionHandler(object):
             # of the request.
             if existed or session:
                 environ[self.session_var] = pickle.dumps(session)
+            response_headers.append(
+                ('X-Launchpad-Revision', versioninfo.revision))
             return start_response(status, response_headers, exc_info)
         return self.application(environ, response_hook)
diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py
index 7eae09a..c4ebbe0 100644
--- a/lib/launchpad_loggerhead/tests.py
+++ b/lib/launchpad_loggerhead/tests.py
@@ -16,6 +16,7 @@ from zope.security.proxy import removeSecurityProxy
 from launchpad_loggerhead.app import RootApp
 from launchpad_loggerhead.session import SessionHandler
 from launchpad_loggerhead.testing import LoggerheadFixture
+from lp.app import versioninfo
 from lp.app.enums import InformationType
 from lp.services.config import config
 from lp.services.webapp.vhosts import allvhosts
@@ -195,3 +196,13 @@ class TestWSGI(TestCaseWithFactory):
             "page title", "title",
             text="%s : changes" % naked_branch.unique_name)
         self.assertThat(response.text, soupmatchers.HTMLContains(title_tag))
+
+    def test_revision_header_present(self):
+        db_branch, _ = self.create_branch_and_tree()
+        branch_url = "http://127.0.0.1:%d/%s"; % (
+            config.codebrowse.port, db_branch.unique_name)
+        response = requests.get(branch_url)
+        self.assertEqual(200, response.status_code)
+        self.assertEqual(
+            versioninfo.revision,
+            response.headers['X-Launchpad-Revision'])

Follow ups