launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24153
[Merge] ~cjwatson/launchpad:build-source-package-version into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:build-source-package-version into launchpad:master.
Commit message:
Export build.source_package_version
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/376459
It's remarkably hard to figure out the source package version for a binary package publication via the API. You can sometimes do it via `bpph.build.getLatestSourcePublication()`, but that might not be visible if the build was performed in a private archive; or you can look at `bpph.build.title`, but that involves parsing non-machine-readable text.
`build.source_package_name` is already exported, so it seems to make sense to export `build.source_package_version` to go with it.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:build-source-package-version into launchpad:master.
diff --git a/lib/lp/soyuz/interfaces/binarypackagebuild.py b/lib/lp/soyuz/interfaces/binarypackagebuild.py
index e63cff1..5284ff1 100644
--- a/lib/lp/soyuz/interfaces/binarypackagebuild.py
+++ b/lib/lp/soyuz/interfaces/binarypackagebuild.py
@@ -102,6 +102,9 @@ class IBinaryPackageBuildView(IPackageBuild):
TextLine(
title=_("Source package name"), required=False, readonly=True),
exported_as="source_package_name")
+ source_package_version = exported(
+ TextLine(
+ title=_("Source package version"), required=False, readonly=True))
distro_series = Attribute("Direct parent needed by CanonicalURL")
arch_tag = exported(
diff --git a/lib/lp/soyuz/model/binarypackagebuild.py b/lib/lp/soyuz/model/binarypackagebuild.py
index 748e102..ae4f1de 100644
--- a/lib/lp/soyuz/model/binarypackagebuild.py
+++ b/lib/lp/soyuz/model/binarypackagebuild.py
@@ -280,6 +280,11 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase):
return self.source_package_release.name
@property
+ def source_package_version(self):
+ """See `IBuild`."""
+ return self.source_package_release.version
+
+ @property
def upload_changesfile(self):
"""See `IBuild`"""
package_upload = self.package_upload
diff --git a/lib/lp/soyuz/stories/webservice/xx-builds.txt b/lib/lp/soyuz/stories/webservice/xx-builds.txt
index cf05b4a..78f3b97 100644
--- a/lib/lp/soyuz/stories/webservice/xx-builds.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-builds.txt
@@ -64,6 +64,7 @@ of properties:
score: None
self_link: u'http://api.launchpad.test/beta/~cprov/+archive/ubuntu/ppa/+build/26'
source_package_name: u'cdrkit'
+ source_package_version: u'1.0'
status: u'Failed to build'
title: u'i386 build of cdrkit 1.0 in ubuntu breezy-autotest RELEASE'
upload_log_url: None
@@ -97,6 +98,7 @@ Whereas the 1.0 webservice for builds maintains the old property names
score: None
self_link: u'http://.../~cprov/+archive/ubuntu/ppa/+build/26'
source_package_name: u'cdrkit'
+ source_package_version: u'1.0'
title: u'i386 build of cdrkit 1.0 in ubuntu breezy-autotest RELEASE'
upload_log_url: None
web_link: u'http://launchpad.../~cprov/+archive/ubuntu/ppa/+build/26'
@@ -131,6 +133,7 @@ devel webservice also contains build date_started and duration.
score: None
self_link: u'http://.../~cprov/+archive/ubuntu/ppa/+build/26'
source_package_name: u'cdrkit'
+ source_package_version: u'1.0'
title: u'i386 build of cdrkit 1.0 in ubuntu breezy-autotest RELEASE'
upload_log_url: None
web_link: u'http://launchpad.../~cprov/+archive/ubuntu/ppa/+build/26'
diff --git a/lib/lp/soyuz/tests/test_binarypackagebuild.py b/lib/lp/soyuz/tests/test_binarypackagebuild.py
index 12de565..1924b37 100644
--- a/lib/lp/soyuz/tests/test_binarypackagebuild.py
+++ b/lib/lp/soyuz/tests/test_binarypackagebuild.py
@@ -579,6 +579,13 @@ class TestBinaryPackageBuildWebservice(TestCaseWithFactory):
entry = self.webservice.get(build_url, api_version='devel').jsonBody()
self.assertEqual(name, entry['source_package_name'])
+ def test_source_package_version(self):
+ version = self.build.source_package_release.version
+ build_url = api_url(self.build)
+ logout()
+ entry = self.webservice.get(build_url, api_version='devel').jsonBody()
+ self.assertEqual(version, entry['source_package_version'])
+
def test_external_dependencies_random_user(self):
# Normal users can look but not touch.
person = self.factory.makePerson()