Merge lp:~wgrant/launchpad/product-index-git into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 18201
Proposed branch: lp:~wgrant/launchpad/product-index-git
Merge into: lp:launchpad
Diff against target: 171 lines (+63/-19)
4 files modified
lib/lp/registry/browser/product.py (+10/-0)
lib/lp/registry/browser/tests/test_product.py (+40/-0)
lib/lp/registry/stories/product/xx-product-code-trunk.txt (+3/-7)
lib/lp/registry/templates/product-index.pt (+10/-12)
To merge this branch: bzr merge lp:~wgrant/launchpad/product-index-git
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+306086@code.launchpad.net

Commit message

Link to the default git repository on Product:+index.

Description of the change

Link to the default git repository on Product:+index.

Also drop the "development focus" terminology from code. The phrase now
exclusively refers to the development focus series, which implies the
code trunk in the Bazaar case.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/product.py'
2--- lib/lp/registry/browser/product.py 2016-07-12 21:15:27 +0000
3+++ lib/lp/registry/browser/product.py 2016-09-19 11:57:07 +0000
4@@ -1132,6 +1132,16 @@
5 true_text='Approved',
6 header='Does the licence qualifiy the project for free hosting?')
7
8+ @property
9+ def code_trunk(self):
10+ if self.context.inferred_vcs == VCSType.GIT:
11+ return getUtility(IGitRepositorySet).getDefaultRepository(
12+ self.context)
13+ elif self.context.inferred_vcs == VCSType.BZR:
14+ return self.context.development_focus.branch
15+ else:
16+ return None
17+
18
19 class ProductPackagesView(LaunchpadView):
20 """View for displaying product packaging"""
21
22=== modified file 'lib/lp/registry/browser/tests/test_product.py'
23--- lib/lp/registry/browser/tests/test_product.py 2016-07-25 04:45:51 +0000
24+++ lib/lp/registry/browser/tests/test_product.py 2016-09-19 11:57:07 +0000
25@@ -17,6 +17,7 @@
26 )
27 from testtools.matchers import (
28 LessThan,
29+ MatchesAll,
30 Not,
31 )
32 import transaction
33@@ -297,6 +298,45 @@
34 super(TestProductView, self).setUp()
35 self.product = self.factory.makeProduct(name='fnord')
36
37+ def test_code_link_bzr(self):
38+ branch = self.factory.makeBranch(target=self.product)
39+ # No browse link unless there are revisions.
40+ self.factory.makeRevisionsForBranch(branch)
41+ with person_logged_in(self.product.owner):
42+ self.product.development_focus.branch = branch
43+ self.product.vcs = VCSType.BZR
44+ view = create_initialized_view(self.product, "+index")
45+ html = view()
46+ self.assertThat(
47+ html,
48+ MatchesAll(
49+ HTMLContains(
50+ Tag("branch link", "a",
51+ text="lp://dev/%s" % self.product.name,
52+ attrs={"href": canonical_url(branch)})),
53+ HTMLContains(
54+ Tag("code browser link", "a", text="Browse the code",
55+ attrs={"href": branch.getCodebrowseUrl('files')}))))
56+
57+ def test_code_link_git(self):
58+ repo = self.factory.makeGitRepository(target=self.product)
59+ with person_logged_in(repo.target.owner):
60+ getUtility(IGitRepositorySet).setDefaultRepository(
61+ target=self.product, repository=repo)
62+ self.product.vcs = VCSType.GIT
63+ view = create_initialized_view(self.product, "+index")
64+ html = view()
65+ self.assertThat(
66+ html,
67+ MatchesAll(
68+ HTMLContains(
69+ Tag("repo link", "a",
70+ text="lp:%s" % self.product.name,
71+ attrs={"href": canonical_url(repo)})),
72+ HTMLContains(
73+ Tag("code browser link", "a", text="Browse the code",
74+ attrs={"href": repo.getCodebrowseUrl()}))))
75+
76 def test_golang_meta_renders_git(self):
77 # ensure golang meta import path is rendered if project has
78 # git default vcs.
79
80=== renamed file 'lib/lp/registry/stories/product/xx-product-development-focus.txt' => 'lib/lp/registry/stories/product/xx-product-code-trunk.txt'
81--- lib/lp/registry/stories/product/xx-product-development-focus.txt 2016-03-23 12:16:54 +0000
82+++ lib/lp/registry/stories/product/xx-product-code-trunk.txt 2016-09-19 11:57:07 +0000
83@@ -34,13 +34,13 @@
84 >>> def print_code_trunk(browser):
85 ... """Print out code trunk part of the project info."""
86 ... project_info = find_tag_by_id(browser.contents, 'code-info')
87- ... dev_focus = project_info.find(attrs={'id':'dev-focus'})
88+ ... code_trunk = project_info.find(attrs={'id':'code-trunk'})
89 ... try:
90- ... print extract_text(dev_focus)
91+ ... print extract_text(code_trunk)
92 ... except TypeError:
93 ... return
94 ... print "Links:"
95- ... for a in dev_focus.findAll('a'):
96+ ... for a in code_trunk.findAll('a'):
97 ... for content in a.contents:
98 ... print content
99 ... title = a.get('title', '')
100@@ -111,7 +111,6 @@
101 trunk series (/fooix/trunk)
102 Change details (http://launchpad.dev/fooix/+edit)
103 >>> print_code_trunk(owner_browser)
104- Development focus:
105 lp://dev/fooix Configure Code
106 Browse the code
107 Links:
108@@ -138,7 +137,6 @@
109 Links:
110 trunk series (/fooix/trunk)
111 >>> print_code_trunk(anon_browser)
112- Development focus:
113 lp://dev/fooix
114 Browse the code
115 Links:
116@@ -153,7 +151,6 @@
117 trunk series (/fooix/trunk)
118 Change details (http://launchpad.dev/fooix/+edit)
119 >>> print_code_trunk(owner_browser)
120- Development focus:
121 lp://dev/fooix Configure Code
122 Browse the code
123 Links:
124@@ -192,7 +189,6 @@
125 Change details
126 (http://launchpad.dev/fooix/+edit)
127 >>> print_code_trunk(owner_browser)
128- Development focus:
129 lp://dev/fooix Configure Code
130 Browse the code
131 Links:
132
133=== modified file 'lib/lp/registry/templates/product-index.pt'
134--- lib/lp/registry/templates/product-index.pt 2016-03-24 11:15:09 +0000
135+++ lib/lp/registry/templates/product-index.pt 2016-09-19 11:57:07 +0000
136@@ -195,7 +195,7 @@
137 section.
138 </tal:comment>
139 <div id="code-info" class="portlet"
140- tal:define="trunk context/development_focus/branch;
141+ tal:define="trunk view/code_trunk;
142 trunk_visible trunk/required:launchpad.View|nothing"
143 tal:condition="python: trunk_visible or context.inferred_vcs">
144 <h2>
145@@ -205,17 +205,15 @@
146 Code
147 </h2>
148
149- <dl id="dev-focus" tal:condition="trunk_visible">
150- <dt>Development focus:</dt>
151- <dd>
152- <p>
153- <a tal:replace="structure trunk/fmt:link" />&nbsp;
154- <a tal:replace="structure context/menu:overview/configure_code/fmt:icon" />
155- <br/>
156- <a tal:replace="structure trunk/menu:context/source/fmt:link"/>
157- </p>
158- </dd>
159- </dl>
160+ <div id="code-trunk"
161+ tal:condition="trunk_visible">
162+ <p tal:condition="trunk_visible">
163+ <a tal:replace="structure trunk/fmt:link" />&nbsp;
164+ <a tal:replace="structure context/menu:overview/configure_code/fmt:icon" />
165+ <br/>
166+ <a tal:replace="structure trunk/menu:context/source/fmt:link"/>
167+ </p>
168+ </div>
169
170 <div class="two-column-list">
171 <dl id="product-vcs" tal:condition="context/inferred_vcs">