launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19255
[Merge] lp:~cjwatson/launchpad/snap-show-source into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/snap-show-source into lp:launchpad.
Commit message:
Show the source (Bazaar or Git branch) on Snap:+index.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snap-show-source/+merge/269404
Show the source (Bazaar or Git branch) on Snap:+index.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snap-show-source into lp:launchpad.
=== modified file 'lib/lp/snappy/browser/snap.py'
--- lib/lp/snappy/browser/snap.py 2015-08-09 22:49:05 +0000
+++ lib/lp/snappy/browser/snap.py 2015-08-27 16:11:59 +0000
@@ -53,6 +53,16 @@
def builds(self):
return builds_for_snap(self.context)
+ @property
+ def source(self):
+ if self.context.branch is not None:
+ return self.context.branch
+ elif self.context.git_repository is not None:
+ return self.context.git_repository.getRefByPath(
+ self.context.git_path)
+ else:
+ return None
+
def builds_for_snap(snap):
"""A list of interesting builds.
=== modified file 'lib/lp/snappy/browser/tests/test_snap.py'
--- lib/lp/snappy/browser/tests/test_snap.py 2015-08-07 10:12:38 +0000
+++ lib/lp/snappy/browser/tests/test_snap.py 2015-08-27 16:11:59 +0000
@@ -74,17 +74,12 @@
self.factory.makeBuilder(virtualized=True)
def makeSnap(self, branch=None, git_ref=None):
- kwargs = {}
if branch is None and git_ref is None:
branch = self.factory.makeAnyBranch()
- if branch is not None:
- kwargs["branch"] = branch
- else:
- kwargs["git_repository"] = git_ref.repository
- kwargs["git_path"] = git_ref.path
return self.factory.makeSnap(
registrant=self.person, owner=self.person,
- distroseries=self.distroseries, name=u"snap-name", **kwargs)
+ distroseries=self.distroseries, name=u"snap-name", branch=branch,
+ git_ref=git_ref)
def makeBuild(self, snap=None, archive=None, date_created=None, **kwargs):
if snap is None:
@@ -98,15 +93,41 @@
distroarchseries=self.distroarchseries, date_created=date_created,
**kwargs)
- def test_index(self):
- build = self.makeBuild(
- status=BuildStatus.FULLYBUILT, duration=timedelta(minutes=30))
- self.assertTextMatchesExpressionIgnoreWhitespace("""\
- Snap packages snap-name
- .*
- Snap package information
- Owner: Test Person
- Distribution series: Ubuntu Shiny
+ def test_index_bzr(self):
+ branch = self.factory.makePersonalBranch(
+ owner=self.person, name="snap-branch")
+ snap = self.makeSnap(branch=branch)
+ build = self.makeBuild(
+ snap=snap, status=BuildStatus.FULLYBUILT,
+ duration=timedelta(minutes=30))
+ self.assertTextMatchesExpressionIgnoreWhitespace("""\
+ Snap packages snap-name
+ .*
+ Snap package information
+ Owner: Test Person
+ Distribution series: Ubuntu Shiny
+ Source: lp://dev/~test-person/\\+junk/snap-branch
+ Latest builds
+ Status When complete Architecture Archive
+ Successfully built 30 minutes ago i386
+ Primary Archive for Ubuntu Linux
+ """, self.getMainText(build.snap))
+
+ def test_index_git(self):
+ [ref] = self.factory.makeGitRefs(
+ owner=self.person, target=self.person, name=u"snap-repository",
+ paths=[u"refs/heads/master"])
+ snap = self.makeSnap(git_ref=ref)
+ build = self.makeBuild(
+ snap=snap, status=BuildStatus.FULLYBUILT,
+ duration=timedelta(minutes=30))
+ self.assertTextMatchesExpressionIgnoreWhitespace("""\
+ Snap packages snap-name
+ .*
+ Snap package information
+ Owner: Test Person
+ Distribution series: Ubuntu Shiny
+ Source: ~test-person/\\+git/snap-repository:master
Latest builds
Status When complete Architecture Archive
Successfully built 30 minutes ago i386
=== modified file 'lib/lp/snappy/templates/snap-index.pt'
--- lib/lp/snappy/templates/snap-index.pt 2015-08-07 10:12:38 +0000
+++ lib/lp/snappy/templates/snap-index.pt 2015-08-27 16:11:59 +0000
@@ -39,6 +39,10 @@
tal:content="distro_series/fullseriesname"/>
</dd>
</dl>
+ <dl id="source" tal:define="source view/source" tal:condition="source">
+ <dt>Source:</dt>
+ <dd tal:content="structure source/fmt:link"/>
+ </dl>
</div>
<h2>Latest builds</h2>
Follow ups