← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~blr/launchpad/golang-meta-import-https-fix into lp:launchpad

 

Bayard 'kit' Randel has proposed merging lp:~blr/launchpad/golang-meta-import-https-fix into lp:launchpad.

Commit message:
Use https for bzr branch url, as `go get` is now restricted to secure vcs urls only.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1465467 in Launchpad itself: "put <meta name="go-import"> tags on project, series pages"
  https://bugs.launchpad.net/launchpad/+bug/1465467

For more details, see:
https://code.launchpad.net/~blr/launchpad/golang-meta-import-https-fix/+merge/263859
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~blr/launchpad/golang-meta-import-https-fix into lp:launchpad.
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py	2015-07-02 22:58:12 +0000
+++ lib/lp/registry/browser/product.py	2015-07-06 02:56:25 +0000
@@ -217,12 +217,12 @@
     stepto,
     structured,
     )
-from lp.services.config import config
 from lp.services.webapp.authorization import check_permission
 from lp.services.webapp.batching import BatchNavigator
 from lp.services.webapp.breadcrumb import Breadcrumb
 from lp.services.webapp.interfaces import UnsafeFormGetSubmissionError
 from lp.services.webapp.menu import NavigationMenu
+from lp.services.webapp.vhosts import allvhosts
 from lp.services.worlddata.helpers import browser_languages
 from lp.services.worlddata.interfaces.country import ICountry
 from lp.translations.browser.customlanguagecode import (
@@ -1032,8 +1032,8 @@
             repo = getUtility(IGitRepositorySet).getDefaultRepository(
                 self.context)
             if repo:
-                return "{base_url}/{product} git {git_https_url}".format(
-                    base_url=config.vhost.mainsite.hostname,
+                return "{hostname}/{product} git {git_https_url}".format(
+                    hostname=config.vhost.mainsite.hostname,
                     product=self.context.name,
                     git_https_url=repo.git_https_url)
             else:
@@ -1041,12 +1041,12 @@
         elif (self.context.vcs == VCSType.BZR and
         self.context.development_focus.branch):
             return (
-                "{base_url}/{product} bzr "
-                "{browse_root}{branch}").format(
-                    base_url=config.vhost.mainsite.hostname,
+                "{hostname}/{product} bzr "
+                "{root_url}{branch}").format(
+                    hostname=config.vhost.mainsite.hostname,
+                    root_url=allvhosts.configs['mainsite'].rooturl,
                     product=self.context.name,
-                    branch=self.context.development_focus.branch.unique_name,
-                    browse_root=config.codehosting.supermirror_root)
+                    branch=self.context.development_focus.branch.unique_name)
         else:
             return None
 

=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py	2015-07-02 22:58:12 +0000
+++ lib/lp/registry/browser/productseries.py	2015-07-06 02:56:25 +0000
@@ -109,6 +109,7 @@
 from lp.services.webapp.batching import BatchNavigator
 from lp.services.webapp.breadcrumb import Breadcrumb
 from lp.services.webapp.escaping import structured
+from lp.services.webapp.vhosts import allvhosts
 from lp.services.worlddata.helpers import browser_languages
 from lp.services.worlddata.interfaces.country import ICountry
 from lp.services.worlddata.interfaces.language import ILanguageSet
@@ -387,12 +388,13 @@
         """
         if (self.context.product.vcs == VCSType.BZR and
             self.context.product.development_focus.branch):
-            return ("{base_url}/{product}/{series} bzr {root}{branch}").format(
-                base_url=config.vhost.mainsite.hostname,
-                product=self.context.product.name,
-                series=self.context.name,
-                branch=self.context.branch.unique_name,
-                root=config.codehosting.supermirror_root)
+            return (
+                "{hostname}/{product}/{series} bzr {root_url}{branch}").format(
+                    hostname=config.vhost.mainsite.hostname,
+                    product=self.context.product.name,
+                    series=self.context.name,
+                    branch=self.context.branch.unique_name,
+                    root_url=allvhosts.configs['mainsite'].rooturl)
         else:
             return None
 

=== modified file 'lib/lp/registry/browser/tests/test_product.py'
--- lib/lp/registry/browser/tests/test_product.py	2015-07-02 08:50:10 +0000
+++ lib/lp/registry/browser/tests/test_product.py	2015-07-06 02:56:25 +0000
@@ -45,6 +45,7 @@
 from lp.services.config import config
 from lp.services.database.interfaces import IStore
 from lp.services.webapp.publisher import canonical_url
+from lp.services.webapp.vhosts import allvhosts
 from lp.testing import (
     BrowserTestCase,
     login_celebrity,
@@ -334,11 +335,10 @@
             branch.product.vcs = VCSType.BZR
 
         golang_import = (
-            "{base}/wapcaplet bzr "
-            "{root}~zardoz/wapcaplet/a-branch").format(
-                base=config.vhost.mainsite.hostname,
-                root=config.codehosting.supermirror_root
-            )
+            "{hostname}/wapcaplet bzr "
+            "{root_url}~zardoz/wapcaplet/a-branch").format(
+                hostname=config.vhost.mainsite.hostname,
+                root_url=allvhosts.configs['mainsite'].rooturl)
         self.assertEqual(golang_import, view.golang_import_spec)
         meta_tag = Tag('go-import-meta', 'meta',
                        attrs={'name': 'go-import', 'content': golang_import})

=== modified file 'lib/lp/registry/browser/tests/test_productseries_views.py'
--- lib/lp/registry/browser/tests/test_productseries_views.py	2015-07-02 22:58:12 +0000
+++ lib/lp/registry/browser/tests/test_productseries_views.py	2015-07-06 02:56:25 +0000
@@ -18,6 +18,7 @@
 from lp.registry.enums import VCSType
 from lp.services.config import config
 from lp.services.webapp import canonical_url
+from lp.services.webapp.vhosts import allvhosts
 from lp.testing import (
     BrowserTestCase,
     person_logged_in,
@@ -47,10 +48,10 @@
             branch.product.vcs = VCSType.BZR
 
         golang_import = (
-            "{base}/wapcaplet/trunk bzr "
-            "{root}~zardoz/wapcaplet/a-branch").format(
-                base=config.vhost.mainsite.hostname,
-                root=config.codehosting.supermirror_root,
+            "{hostname}/wapcaplet/trunk bzr "
+            "{root_url}~zardoz/wapcaplet/a-branch").format(
+                hostname=config.vhost.mainsite.hostname,
+                root_url=allvhosts.configs['mainsite'].rooturl,
             )
         self.assertEqual(golang_import, view.golang_import_spec)
         meta_tag = soupmatchers.Tag('go-import-meta', 'meta',


Follow ups