← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/package-git-link into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/package-git-link into lp:launchpad.

Commit message:
Add git links to DistributionSourcePackage:+branches and DistributionSourcePackage:+all-branches.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1511573 in Launchpad itself: "Ubuntu packages miss "View Git Repositories" on the code page even when there are git repos with the target set"
  https://bugs.launchpad.net/launchpad/+bug/1511573

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/package-git-link/+merge/276419

Add git links to DistributionSourcePackage:+branches and DistributionSourcePackage:+all-branches.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/package-git-link into lp:launchpad.
=== modified file 'lib/lp/code/browser/branchlisting.py'
--- lib/lp/code/browser/branchlisting.py	2015-09-23 17:51:12 +0000
+++ lib/lp/code/browser/branchlisting.py	2015-11-02 16:38:03 +0000
@@ -1361,6 +1361,8 @@
 class DistributionSourcePackageBranchesView(BaseSourcePackageBranchesView):
     """A general listing of all branches in the distro source package."""
 
+    can_have_git_link = True
+
     def _getCollection(self):
         return getUtility(IAllBranches).inDistributionSourcePackage(
             self.context)
@@ -1540,6 +1542,11 @@
                      })
         return result
 
+    @property
+    def show_git_link(self):
+        c = IGitCollection(self.context)
+        return not c.visibleByUser(self.user).is_empty()
+
 
 class SourcePackageBranchesView(BranchListingView):
 

=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
--- lib/lp/code/browser/tests/test_branchlisting.py	2015-09-28 17:38:45 +0000
+++ lib/lp/code/browser/tests/test_branchlisting.py	2015-11-02 16:38:03 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for branch listing."""
@@ -618,6 +618,16 @@
             series_branches_last_row.text_content(),
             DocTestMatches("%s ... ago" % branch.displayname))
 
+    def test_git_link(self):
+        page = create_initialized_view(
+            self.distro_source_package, name='+branches', rootsite='code')()
+        self.assertNotIn('View Git repositories', page)
+
+        self.factory.makeGitRepository(target=self.distro_source_package)
+        page = create_initialized_view(
+            self.distro_source_package, name='+branches', rootsite='code')()
+        self.assertIn('View Git repositories', page)
+
 
 class TestDevelopmentFocusPackageBranches(TestCaseWithFactory):
     """Make sure that the bzr_identity of the branches are correct."""

=== modified file 'lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt'
--- lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt	2014-02-25 06:38:58 +0000
+++ lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt	2015-11-02 16:38:03 +0000
@@ -10,6 +10,10 @@
 
 <div metal:fill-slot="main">
 
+  <span class="see-all" tal:condition="view/show_git_link">
+    <a tal:attributes="href context/fmt:url:code/+git">View Git repositories</a>
+  </span>
+
   <p id="distro-branch-warning">
     <strong>This page is for a packaging branch for a program in
     <tal:name replace="context/distribution/displayname"/>.</strong> Changes


Follow ups