launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19393
[Merge] lp:~cjwatson/launchpad/polish-gitref-index into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/polish-gitref-index into lp:launchpad.
Commit message:
Add some more information to the top of GitRef:+index.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/polish-gitref-index/+merge/271673
The top of GitRef:+index is currently rather sparse: there's no link to a code browser other than the tip commit link, and no instructions on how to clone the branch locally. This adds some suitable information so that it looks mostly like the top of GitRepository:+index.
I tidied up one or two other things in the same areas in the process. Some portlets are no longer shown if they would be empty, and we now include a URL with the "git push" instruction (partly because otherwise we can't include a branch name, but I think it's a good idea anyway in case the remote isn't the default).
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/polish-gitref-index into lp:launchpad.
=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml 2015-09-17 12:13:31 +0000
+++ lib/lp/code/browser/configure.zcml 2015-09-18 15:42:51 +0000
@@ -808,6 +808,11 @@
template="../templates/gitrepository-portlet-subscribers-content.pt"/>
<browser:page
for="lp.code.interfaces.gitrepository.IGitRepository"
+ name="+macros"
+ permission="zope.Public"
+ template="../templates/git-macros.pt"/>
+ <browser:page
+ for="lp.code.interfaces.gitrepository.IGitRepository"
class="lp.code.browser.gitrepository.GitRepositoryEditInformationTypeView"
permission="launchpad.Edit"
name="+edit-information-type"
@@ -878,12 +883,15 @@
<browser:page
name="++ref-pending-merges"
template="../templates/gitref-pending-merges.pt"/>
+ <browser:page
+ name="++ref-management"
+ template="../templates/gitref-management.pt"/>
</browser:pages>
<browser:page
for="lp.code.interfaces.gitref.IGitRef"
name="+macros"
permission="zope.Public"
- template="../templates/gitref-macros.pt"/>
+ template="../templates/git-macros.pt"/>
<browser:page
for="lp.code.interfaces.gitref.IGitRefBatchNavigator"
permission="zope.Public"
=== modified file 'lib/lp/code/browser/gitref.py'
--- lib/lp/code/browser/gitref.py 2015-09-18 10:38:27 +0000
+++ lib/lp/code/browser/gitref.py 2015-09-18 15:42:51 +0000
@@ -84,7 +84,13 @@
usedfor = IGitRef
facet = 'branches'
- links = ['create_snap', 'register_merge']
+ links = ['create_snap', 'register_merge', 'source']
+
+ def source(self):
+ """Return a link to the branch's browsing interface."""
+ text = "Browse the code"
+ url = self.context.getCodebrowseUrl()
+ return Link(url, text, icon="info")
def register_merge(self):
text = 'Propose for merging'
@@ -99,6 +105,11 @@
return self.context.display_name
@property
+ def user_can_push(self):
+ """Whether the user can push to this branch."""
+ return check_permission("launchpad.Edit", self.context)
+
+ @property
def tip_commit_info(self):
return {
"sha1": self.context.commit_sha1,
=== modified file 'lib/lp/code/browser/gitrepository.py'
--- lib/lp/code/browser/gitrepository.py 2015-09-16 13:30:33 +0000
+++ lib/lp/code/browser/gitrepository.py 2015-09-18 15:42:51 +0000
@@ -217,7 +217,7 @@
return Link("+addsubscriber", text, icon="add")
def source(self):
- """Return a link to the branch's browsing interface."""
+ """Return a link to the repository's browsing interface."""
text = "Browse the code"
url = self.context.getCodebrowseUrl()
return Link(url, text, icon="info")
=== modified file 'lib/lp/code/browser/tests/test_gitref.py'
--- lib/lp/code/browser/tests/test_gitref.py 2015-09-10 11:20:58 +0000
+++ lib/lp/code/browser/tests/test_gitref.py 2015-09-18 15:42:51 +0000
@@ -11,12 +11,12 @@
from zope.component import getUtility
from lp.code.interfaces.gitrepository import IGitRepositorySet
-from lp.testing import TestCaseWithFactory
+from lp.testing import BrowserTestCase
from lp.testing.layers import DatabaseFunctionalLayer
from lp.testing.views import create_view
-class GitRefView(TestCaseWithFactory):
+class TestGitRefView(BrowserTestCase):
layer = DatabaseFunctionalLayer
@@ -56,3 +56,11 @@
soupmatchers.Tag(
'git ref breadcrumb', 'li',
text=re.compile(r'\smaster\s')))))
+
+ def test_clone_instructions(self):
+ [ref] = self.factory.makeGitRefs(paths=[u"refs/heads/branch"])
+ text = self.getMainText(ref, "+index", user=ref.owner)
+ self.assertTextMatchesExpressionIgnoreWhitespace(r"""
+ git clone -b branch https://.*
+ git clone -b branch git\+ssh://.*
+ """, text)
=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
--- lib/lp/code/browser/tests/test_gitrepository.py 2015-06-18 20:18:16 +0000
+++ lib/lp/code/browser/tests/test_gitrepository.py 2015-09-18 15:42:51 +0000
@@ -78,6 +78,14 @@
layer = DatabaseFunctionalLayer
+ def test_clone_instructions(self):
+ repository = self.factory.makeGitRepository()
+ text = self.getMainText(repository, "+index", user=repository.owner)
+ self.assertTextMatchesExpressionIgnoreWhitespace(r"""
+ git clone https://.*
+ git clone git\+ssh://.*
+ """, text)
+
def test_user_can_push(self):
# A user can push if they have edit permissions.
repository = self.factory.makeGitRepository()
=== renamed file 'lib/lp/code/templates/gitref-macros.pt' => 'lib/lp/code/templates/git-macros.pt'
--- lib/lp/code/templates/gitref-macros.pt 2015-05-11 20:42:33 +0000
+++ lib/lp/code/templates/git-macros.pt 2015-09-18 15:42:51 +0000
@@ -3,6 +3,101 @@
xmlns:metal="http://xml.zope.org/namespaces/metal"
omit-tag="">
+<div
+ metal:define-macro="management"
+ tal:define="context_menu view/context/menu:context">
+
+ <tal:comment condition="nothing">
+ This macro requires the following defined variables:
+ kind - the kind of object being described (branch or repository)
+ repository - the underlying Git repository
+ This variable may optionally be set:
+ branch_name - the branch name
+ </tal:comment>
+
+ <dl id="clone-url">
+ <dt>Get this <tal:kind replace="kind" />:</dt>
+ <dd>
+ <tal:anonymous condition="repository/git_https_url">
+ <tt class="command">
+ git clone
+ <tal:branch condition="branch_name|nothing" replace="string:-b ${branch_name}" />
+ <span class="https-url" tal:content="repository/git_https_url" />
+ </tt>
+ <br />
+ </tal:anonymous>
+ <tal:ssh condition="view/user">
+ <tt class="command">
+ git clone
+ <tal:branch condition="branch_name|nothing" replace="string:-b ${branch_name}" />
+ <span class="ssh-url" tal:content="repository/git_ssh_url" />
+ </tt>
+ </tal:ssh>
+ </dd>
+ </dl>
+
+ <div id="upload-directions">
+ <tal:not-logged-in condition="not:view/user">
+ <tal:individual condition="not:context/owner/is_team">
+ Only
+ <a tal:attributes="href context/owner/fmt:url"
+ tal:content="context/owner/displayname">Person</a>
+ can upload to this <tal:kind replace="kind" />. If you are
+ <tal:branch-owner replace="context/owner/displayname"/>
+ please <a href="+login">log in</a> for upload directions.
+ </tal:individual>
+ <tal:team tal:condition="context/owner/is_team">
+ Members of
+ <a tal:attributes="href context/owner/fmt:url"
+ tal:content="context/owner/displayname">Team</a>
+ can upload to this <tal:kind replace="kind" />.
+ <a href="+login">Log in</a> for directions.
+ </tal:team>
+ </tal:not-logged-in>
+
+ <tal:logged-in condition="view/user">
+ <tal:can-push tal:condition="view/user_can_push">
+ <dl id="push-url">
+ <dt>Update this repository:</dt>
+ <dd>
+ <tt class="command">
+ git push
+ <span class="ssh-url" tal:content="repository/git_ssh_url" />
+ <tal:branch condition="branch_name|nothing" replace="branch_name" />
+ </tt>
+ </dd>
+ </dl>
+ <p tal:condition="not:view/user/sshkeys" id="ssh-key-directions">
+ To authenticate with the Launchpad Git hosting service, you need to
+ <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
+ register a SSH key</a>.
+ </p>
+ </tal:can-push>
+
+ <tal:cannot-push condition="not:view/user_can_push">
+ <div id="push-directions" tal:condition="not:context/owner/is_team">
+ You cannot push to this <tal:kind replace="kind" />. Only
+ <a tal:attributes="href context/owner/fmt:url"
+ tal:content="context/owner/displayname">Person</a>
+ can push to this <tal:kind replace="kind" />.
+ </div>
+ <div id="push-directions" tal:condition="context/owner/is_team">
+ You cannot push to this <tal:kind replace="kind" />. Members of
+ <a tal:attributes="href context/owner/fmt:url"
+ tal:content="context/owner/displayname">Team</a>
+ can push to this <tal:kind replace="kind" />.
+ </div>
+ </tal:cannot-push>
+ </tal:logged-in>
+
+ </div>
+
+ <div style="margin-top: 1.5em" tal:define="link context_menu/source">
+ <a tal:replace="structure link/fmt:link" />
+ </div>
+
+</div>
+
<metal:commit-text define-macro="commit-text">
<tal:comment condition="nothing">
=== modified file 'lib/lp/code/templates/gitref-index.pt'
--- lib/lp/code/templates/gitref-index.pt 2015-09-17 12:13:31 +0000
+++ lib/lp/code/templates/gitref-index.pt 2015-09-18 15:42:51 +0000
@@ -16,8 +16,16 @@
<div metal:fill-slot="main">
+ <div class="yui-g first">
+ <div id="ref-management" class="portlet">
+ <tal:ref-management
+ replace="structure context/@@++ref-management" />
+ </div>
+ </div>
+
<div class="yui-g">
- <div id="ref-relations" class="portlet">
+ <div id="ref-relations" class="portlet"
+ tal:condition="python: view.show_merge_links or view.show_snap_information">
<tal:ref-pending-merges
replace="structure context/@@++ref-pending-merges" />
<div metal:use-macro="context/@@+snap-macros/related-snaps" />
=== added file 'lib/lp/code/templates/gitref-management.pt'
--- lib/lp/code/templates/gitref-management.pt 1970-01-01 00:00:00 +0000
+++ lib/lp/code/templates/gitref-management.pt 2015-09-18 15:42:51 +0000
@@ -0,0 +1,13 @@
+<tal:root
+ xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ omit-tag="">
+
+<tal:repository-management
+ define="kind string:branch;
+ repository context/repository;
+ branch_name context/name">
+ <div metal:use-macro="context/@@+macros/management" />
+</tal:repository-management>
+
+</tal:root>
=== modified file 'lib/lp/code/templates/gitrepository-index.pt'
--- lib/lp/code/templates/gitrepository-index.pt 2015-09-17 12:13:31 +0000
+++ lib/lp/code/templates/gitrepository-index.pt 2015-09-18 15:42:51 +0000
@@ -41,7 +41,8 @@
</div>
<div class="yui-g">
- <div id="repository-relations" class="portlet">
+ <div id="repository-relations" class="portlet"
+ tal:condition="view/show_snap_information">
<div metal:use-macro="context/@@+snap-macros/related-snaps">
<metal:context-type fill-slot="context_type">repository</metal:context-type>
</div>
=== modified file 'lib/lp/code/templates/gitrepository-management.pt'
--- lib/lp/code/templates/gitrepository-management.pt 2015-06-12 08:20:17 +0000
+++ lib/lp/code/templates/gitrepository-management.pt 2015-09-18 15:42:51 +0000
@@ -1,82 +1,12 @@
-<div
+<tal:root
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n"
- tal:define="context_menu view/context/menu:context">
-
- <dl id="clone-url">
- <dt>Get this repository:</dt>
- <dd>
- <tal:anonymous condition="context/git_https_url">
- <tt class="command">
- git clone <span class="https-url" tal:content="context/git_https_url" />
- </tt>
- <br />
- </tal:anonymous>
- <tal:ssh condition="view/user">
- <tt class="command">
- git clone <span class="ssh-url" tal:content="context/git_ssh_url" />
- </tt>
- </tal:ssh>
- </dd>
- </dl>
-
- <div id="upload-directions">
- <tal:not-logged-in condition="not:view/user">
- <tal:individual condition="not:context/owner/is_team">
- Only
- <a tal:attributes="href context/owner/fmt:url"
- tal:content="context/owner/displayname">Person</a>
- can upload to this repository. If you are
- <tal:branch-owner replace="context/owner/displayname"/>
- please <a href="+login">log in</a> for upload directions.
- </tal:individual>
- <tal:team tal:condition="context/owner/is_team">
- Members of
- <a tal:attributes="href context/owner/fmt:url"
- tal:content="context/owner/displayname">Team</a>
- can upload to this repository. <a href="+login">Log in</a> for
- directions.
- </tal:team>
- </tal:not-logged-in>
-
- <tal:logged-in condition="view/user">
- <tal:can-push tal:condition="view/user_can_push">
- <dl id="push-url">
- <dt>Update this repository:</dt>
- <dd>
- <tt class="command">
- git push
- </tt>
- </dd>
- </dl>
- <p tal:condition="not:view/user/sshkeys" id="ssh-key-directions">
- To authenticate with the Launchpad Git hosting service, you need to
- <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
- register a SSH key</a>.
- </p>
- </tal:can-push>
-
- <tal:cannot-push condition="not:view/user_can_push">
- <div id="push-directions" tal:condition="not:context/owner/is_team">
- You cannot push to this repository. Only
- <a tal:attributes="href context/owner/fmt:url"
- tal:content="context/owner/displayname">Person</a>
- can push to this repository.
- </div>
- <div id="push-directions" tal:condition="context/owner/is_team">
- You cannot push to this repository. Members of
- <a tal:attributes="href context/owner/fmt:url"
- tal:content="context/owner/displayname">Team</a>
- can push to this repository.
- </div>
- </tal:cannot-push>
- </tal:logged-in>
-
- </div>
-
- <div style="margin-top: 1.5em" tal:define="link context_menu/source">
- <a tal:replace="structure link/fmt:link" />
- </div>
-
-</div>
+ omit-tag="">
+
+<tal:repository-management
+ define="kind string:repository;
+ repository context">
+ <div metal:use-macro="context/@@+macros/management" />
+</tal:repository-management>
+
+</tal:root>
Follow ups