From b40d856e6745615c887b5a662606c51e54cdc53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Mon, 7 Dec 2015 10:05:08 +0100 Subject: [PATCH] add --limit option to buildhistory --- NEWS | 1 + osc/commandline.py | 4 +++- osc/core.py | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 14634c62..a29c964f 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ - "my sr" is using the server side request collection to get right results - maintenance request offers to supersede old, but still open requests - add build --vm-telnet option for getting debug shell in KVM builds + - add buildhistory --limit option OBS 2.7 only: - add "addchannels" and "enablechannel" commands - support new package instances on branching when using -N parameter diff --git a/osc/commandline.py b/osc/commandline.py index 3f34a54b..de3a6d52 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6088,6 +6088,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('', '--csv', action='store_true', help='generate output in CSV (separated by |)') + @cmdln.option('-l', '--limit', metavar='limit', + help='for setting the number of results') @cmdln.alias('buildhist') def do_buildhistory(self, subcmd, opts, *args): """${cmd_name}: Shows the build history of a package @@ -6126,7 +6128,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.csv: format = 'csv' - print('\n'.join(get_buildhistory(apiurl, project, package, repository, arch, format))) + print('\n'.join(get_buildhistory(apiurl, project, package, repository, arch, format, opts.limit))) @cmdln.option('', '--csv', action='store_true', help='generate output in CSV (separated by |)') diff --git a/osc/core.py b/osc/core.py index 17717072..f6fd6a72 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5791,9 +5791,12 @@ def get_source_rev(apiurl, project, package, revision=None): e[k.tag] = k.text return e -def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text'): +def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', limit = None): import time - u = makeurl(apiurl, ['build', prj, repository, arch, package, '_history']) + query = {} + if limit != None and int(limit) > 0: + query['limit'] = int(limit) + u = makeurl(apiurl, ['build', prj, repository, arch, package, '_history'], query) f = http_GET(u) root = ET.parse(f).getroot()