check tag existence in list-tagged cmd and listTagged* APIs

This commit is contained in:
Yuming Zhu 2018-05-11 16:47:39 +08:00 committed by Mike McLean
parent 90a942f4ee
commit 4a89f8a145
2 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -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,