From 4a89f8a145157c1022df2ec230c8f94d510cbfc0 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Fri, 11 May 2018 16:47:39 +0800 Subject: [PATCH] check tag existence in list-tagged cmd and listTagged* APIs --- cli/koji_cli/commands.py | 7 +++++++ hub/kojihub.py | 14 ++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index df4600d7..60f644aa 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -2421,12 +2421,19 @@ def anon_handle_list_tagged(goptions, session, args): if options.type: opts['type'] = options.type event = koji.util.eventFromOpts(session, options) + event_id = None if event: opts['event'] = event['id'] + event_id = event['id'] event['timestr'] = time.asctime(time.localtime(event['ts'])) if not options.quiet: print("Querying at event %(id)i (%(timestr)s)" % event) + # check if tag exist(s|ed) + taginfo = session.getTag(tag, event=event_id) + if not taginfo: + parser.error(_("No such tag: %s" % tag)) + if options.rpms: rpms, builds = session.listTaggedRPMS(tag, **opts) data = rpms diff --git a/hub/kojihub.py b/hub/kojihub.py index fa70b830..54aa1b8e 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -9729,9 +9729,8 @@ class RootExports(object): def listTagged(self, tag, event=None, inherit=False, prefix=None, latest=False, package=None, owner=None, type=None): """List builds tagged with tag""" - if not isinstance(tag, six.integer_types): - #lookup tag id - tag = get_tag_id(tag, strict=True) + #lookup tag id + tag = get_tag(tag, strict=True, event=event)['id'] results = readTaggedBuilds(tag, event, inherit=inherit, latest=latest, package=package, owner=owner, type=type) if prefix: prefix = prefix.lower() @@ -9740,15 +9739,14 @@ class RootExports(object): def listTaggedRPMS(self, tag, event=None, inherit=False, latest=False, package=None, arch=None, rpmsigs=False, owner=None, type=None): """List rpms and builds within tag""" - if not isinstance(tag, six.integer_types): - #lookup tag id - tag = get_tag_id(tag, strict=True) + #lookup tag id + tag = get_tag(tag, strict=True, event=event)['id'] return readTaggedRPMS(tag, event=event, inherit=inherit, latest=latest, package=package, arch=arch, rpmsigs=rpmsigs, owner=owner, type=type) def listTaggedArchives(self, tag, event=None, inherit=False, latest=False, package=None, type=None): """List archives and builds within a tag""" - if not isinstance(tag, six.integer_types): - tag = get_tag_id(tag, strict=True) + # lookup tag id + tag = get_tag(tag, strict=True, event=event)['id'] return readTaggedArchives(tag, event=event, inherit=inherit, latest=latest, package=package, type=type) def listBuilds(self, packageID=None, userID=None, taskID=None, prefix=None, state=None,