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

Proposed by Colin Watson
Status: Merged
Merged at revision: 17842
Proposed branch: lp:~cjwatson/launchpad/package-git-link
Merge into: lp:launchpad
Diff against target: 66 lines (+22/-1)
3 files modified
lib/lp/code/browser/branchlisting.py (+7/-0)
lib/lp/code/browser/tests/test_branchlisting.py (+11/-1)
lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt (+4/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/package-git-link
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+276419@code.launchpad.net

Commit message

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

Description of the change

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

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branchlisting.py'
2--- lib/lp/code/browser/branchlisting.py 2015-09-23 17:51:12 +0000
3+++ lib/lp/code/browser/branchlisting.py 2015-11-02 16:38:03 +0000
4@@ -1361,6 +1361,8 @@
5 class DistributionSourcePackageBranchesView(BaseSourcePackageBranchesView):
6 """A general listing of all branches in the distro source package."""
7
8+ can_have_git_link = True
9+
10 def _getCollection(self):
11 return getUtility(IAllBranches).inDistributionSourcePackage(
12 self.context)
13@@ -1540,6 +1542,11 @@
14 })
15 return result
16
17+ @property
18+ def show_git_link(self):
19+ c = IGitCollection(self.context)
20+ return not c.visibleByUser(self.user).is_empty()
21+
22
23 class SourcePackageBranchesView(BranchListingView):
24
25
26=== modified file 'lib/lp/code/browser/tests/test_branchlisting.py'
27--- lib/lp/code/browser/tests/test_branchlisting.py 2015-09-28 17:38:45 +0000
28+++ lib/lp/code/browser/tests/test_branchlisting.py 2015-11-02 16:38:03 +0000
29@@ -1,4 +1,4 @@
30-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
31+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
32 # GNU Affero General Public License version 3 (see the file LICENSE).
33
34 """Tests for branch listing."""
35@@ -618,6 +618,16 @@
36 series_branches_last_row.text_content(),
37 DocTestMatches("%s ... ago" % branch.displayname))
38
39+ def test_git_link(self):
40+ page = create_initialized_view(
41+ self.distro_source_package, name='+branches', rootsite='code')()
42+ self.assertNotIn('View Git repositories', page)
43+
44+ self.factory.makeGitRepository(target=self.distro_source_package)
45+ page = create_initialized_view(
46+ self.distro_source_package, name='+branches', rootsite='code')()
47+ self.assertIn('View Git repositories', page)
48+
49
50 class TestDevelopmentFocusPackageBranches(TestCaseWithFactory):
51 """Make sure that the bzr_identity of the branches are correct."""
52
53=== modified file 'lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt'
54--- lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt 2014-02-25 06:38:58 +0000
55+++ lib/lp/code/templates/distributionsourcepackage-branches-grouped.pt 2015-11-02 16:38:03 +0000
56@@ -10,6 +10,10 @@
57
58 <div metal:fill-slot="main">
59
60+ <span class="see-all" tal:condition="view/show_git_link">
61+ <a tal:attributes="href context/fmt:url:code/+git">View Git repositories</a>
62+ </span>
63+
64 <p id="distro-branch-warning">
65 <strong>This page is for a packaging branch for a program in
66 <tal:name replace="context/distribution/displayname"/>.</strong> Changes