launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18815
[Merge] lp:~blr/launchpad/project-meta-go-import into lp:launchpad
Bayard 'kit' Randel has proposed merging lp:~blr/launchpad/project-meta-go-import into lp:launchpad with lp:~blr/launchpad/ui-project-setbranch as a prerequisite.
Commit message:
Add a go-lang remote import meta tag for git and bzr support.
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/project-meta-go-import/+merge/262550
Provides a meta tag with default git repository and bzr branch metadata on Project +index/ProductSeries +index for golang's `go get`.
See: https://golang.org/cmd/go/#hdr-Remote_import_paths
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~blr/launchpad/project-meta-go-import into lp:launchpad.
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2015-06-21 22:09:07 +0000
+++ lib/lp/registry/browser/product.py 2015-06-21 22:09:07 +0000
@@ -165,7 +165,7 @@
from lp.code.interfaces.gitcollection import IGitCollection
from lp.code.interfaces.gitrepository import IGitRepositorySet
from lp.code.browser.vcslisting import TargetDefaultVCSNavigationMixin
-
+from lp.code.interfaces.gitrepository import IGitRepositorySet
from lp.registry.browser import (
add_subscribe_link,
BaseRdfView,
@@ -221,6 +221,7 @@
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
@@ -1026,6 +1027,29 @@
def requestCountry(self):
return ICountry(self.request, None)
+ @property
+ def golang_import_spec(self):
+ """Meta string for golang remote import path.
+ See: https://golang.org/cmd/go/#hdr-Remote_import_paths
+ """
+ if self.context.vcs == VCSType.GIT:
+ repo = getUtility(IGitRepositorySet).getDefaultRepository(
+ self.context)
+ if repo:
+ return "{base_url}/{product} git {git_https_url}".format(
+ base_url=config.launchpad.non_restricted_hostname,
+ product=self.context.name,
+ git_https_url=repo.git_https_url)
+ else:
+ return None
+ elif self.context.vcs == VCSType.BZR:
+ return "{base_url}/{product} bzr {codebrowse_root}{product}".format(
+ base_url=config.launchpad.non_restricted_hostname,
+ product=self.context.name,
+ codebrowse_root=config.codehosting.secure_codebrowse_root)
+ else:
+ return None
+
def browserLanguages(self):
return browser_languages(self.request)
=== modified file 'lib/lp/registry/browser/tests/test_product.py'
--- lib/lp/registry/browser/tests/test_product.py 2015-06-21 22:09:07 +0000
+++ lib/lp/registry/browser/tests/test_product.py 2015-06-21 22:09:07 +0000
@@ -27,6 +27,7 @@
PROPRIETARY_INFORMATION_TYPES,
ServiceUsage,
)
+from lp.code.interfaces.gitrepository import IGitRepositorySet
from lp.registry.browser.product import (
ProjectAddStepOne,
ProjectAddStepTwo,
@@ -295,6 +296,40 @@
super(TestProductView, self).setUp()
self.product = self.factory.makeProduct(name='fnord')
+ def test_golang_meta_renders_git(self):
+ # ensure golang meta import path is rendered if project has
+ # git default vcs.
+ # See: https://golang.org/cmd/go/#hdr-Remote_import_paths
+ repo = self.factory.makeGitRepository()
+ view = create_initialized_view(repo.target, '+index')
+ with person_logged_in(repo.target.owner):
+ getUtility(IGitRepositorySet).setDefaultRepository(
+ target=repo.target, repository=repo)
+ repo.target.vcs = VCSType.GIT
+
+ golang_import = '{base}/{product_name} git {repo_url}'.format(
+ base=config.launchpad.non_restricted_hostname,
+ product_name=repo.target.name,
+ repo_url=repo.git_https_url
+ )
+ self.assertEqual(golang_import, view.golang_import_spec)
+
+ def test_golang_meta_renders_bzr(self):
+ # ensure golang meta import path is rendered if project has
+ # bzr default vcs.
+ # See: https://golang.org/cmd/go/#hdr-Remote_import_paths
+ branch = self.factory.makeBranch()
+ view = create_initialized_view(branch.product, '+index')
+ with person_logged_in(branch.product.owner):
+ branch.product.vcs = VCSType.BZR
+
+ golang_import = '{base}/{name} bzr {repo_url}{name}'.format(
+ base=config.launchpad.non_restricted_hostname,
+ name=branch.target.name,
+ repo_url=config.codehosting.secure_codebrowse_root
+ )
+ self.assertEqual(golang_import, view.golang_import_spec)
+
def test_show_programming_languages_without_languages(self):
# show_programming_languages is false when there are no programming
# languages set.
=== modified file 'lib/lp/registry/browser/tests/test_productseries_views.py'
--- lib/lp/registry/browser/tests/test_productseries_views.py 2013-04-03 03:09:04 +0000
+++ lib/lp/registry/browser/tests/test_productseries_views.py 2015-06-21 22:09:07 +0000
@@ -30,6 +30,22 @@
layer = DatabaseFunctionalLayer
+ def test_golang_meta_renders(self):
+ # ensure golang meta import path is rendered if project series has
+ # git default.
+ # See: https://golang.org/cmd/go/#hdr-Remote_import_paths
+ repo = self.factory.makeGitRepository()
+ view = create_initialized_view(repo.target, '+index')
+ with person_logged_in(repo.target.owner):
+ getUtility(IGitRepositorySet).setDefaultRepository(
+ target=repo.target, repository=repo)
+ golang_import = '{base}/{product_name} git {repo_url}'.format(
+ base=config.launchpad.non_restricted_hostname,
+ product_name=repo.target.name,
+ repo_url=repo.git_https_url
+ )
+ self.assertEqual(golang_import, view.golang_import_spec)
+
def test_information_type_public(self):
# A ProductSeries view should include its information_type,
# which defaults to Public for new projects.
=== modified file 'lib/lp/registry/templates/product-index.pt'
--- lib/lp/registry/templates/product-index.pt 2015-06-21 22:09:07 +0000
+++ lib/lp/registry/templates/product-index.pt 2015-06-21 22:09:07 +0000
@@ -25,6 +25,9 @@
});
</script>
</tal:uses_launchpad_bugtracker>
+
+ <meta name="go-import" tal:condition="view/golang_import_spec"
+ tal:attributes="content view/golang_import_spec" />
</tal:head-epilogue>
</head>
Follow ups