1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

"maintainer --user" support to search for all official maintained instance for given user or group

This commit is contained in:
Adrian Schröter 2013-02-20 11:41:17 +01:00
parent f0d1acf8d4
commit 220ec0e2cf
3 changed files with 61 additions and 39 deletions

1
NEWS
View File

@ -2,6 +2,7 @@
- support generic emulator virtualization - support generic emulator virtualization
- added "--host" argument to "osc build" (used to perform the build on a remote host) - added "--host" argument to "osc build" (used to perform the build on a remote host)
- "search --maintained" is obsolete. Abort on usage. - "search --maintained" is obsolete. Abort on usage.
- "maintainer --user" support to search for all official maintained instance for given user or group
0.138 0.138
- add support to remove repositories recursively (mostly only usefull for admins) - add support to remove repositories recursively (mostly only usefull for admins)

View File

@ -6111,7 +6111,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
"""${cmd_name}: show waiting work, packages, projects or requests involving yourself """${cmd_name}: show waiting work, packages, projects or requests involving yourself
Examples: Examples:
# list all tasks where it is expected to work on # list all open tasks for me
osc ${cmd_name} [work] osc ${cmd_name} [work]
# list packages where I am bugowner # list packages where I am bugowner
osc ${cmd_name} pkg -b osc ${cmd_name} pkg -b
@ -6769,6 +6769,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Set the bugowner to specified person') help='Set the bugowner to specified person')
@cmdln.option('-S', '--set-bugowner-request', metavar='user', @cmdln.option('-S', '--set-bugowner-request', metavar='user',
help='Set the bugowner to specified person via a request') help='Set the bugowner to specified person via a request')
@cmdln.option('-U', '--user', metavar='USER',
help='All official maintained instances for the specified USER')
@cmdln.option('-G', '--group', metavar='GROUP',
help='All official maintained instances for the specified GROUP')
@cmdln.option('-d', '--delete', metavar='user', @cmdln.option('-d', '--delete', metavar='user',
help='delete a maintainer/bugowner (can be specified via --role)') help='delete a maintainer/bugowner (can be specified via --role)')
@cmdln.option('-r', '--role', metavar='role', action='append', default=[], @cmdln.option('-r', '--role', metavar='role', action='append', default=[],
@ -6777,8 +6781,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
def do_maintainer(self, subcmd, opts, *args): def do_maintainer(self, subcmd, opts, *args):
"""${cmd_name}: Show maintainers of a project/package """${cmd_name}: Show maintainers of a project/package
osc maintainer <options> # Search for official maintained sources in OBS instance
osc maintainer BINARY <options> osc maintainer BINARY <options>
osc maintainer -U <user> <options>
osc maintainer -G <group> <options>
# Lookup in specific containers
osc maintainer <options>
osc maintainer PRJ <options> osc maintainer PRJ <options>
osc maintainer PRJ PKG <options> osc maintainer PRJ PKG <options>
@ -6804,7 +6813,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
roles = [ 'bugowner' ] roles = [ 'bugowner' ]
args = slash_split(args) args = slash_split(args)
if len(args) == 0: if opts.user or opts.group:
if len(args) != 0:
raise oscerr.WrongArgs('Either search for user or for packages.')
elif len(args) == 0:
try: try:
pac = store_read_package('.') pac = store_read_package('.')
except oscerr.NoWorkingCopy: except oscerr.NoWorkingCopy:
@ -6822,7 +6834,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url() apiurl = self.get_api_url()
# Try the OBS 2.4 way first. # Try the OBS 2.4 way first.
if pac==None and binary: if binary or opts.user or opts.group:
limit=None limit=None
if opts.all: if opts.all:
limit=0 limit=0
@ -6830,7 +6842,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if filterroles == [ 'bugowner', 'maintainer' ]: if filterroles == [ 'bugowner', 'maintainer' ]:
# use server side configured default # use server side configured default
filterroles=None filterroles=None
searchresult = owner(apiurl, binary, usefilter=filterroles, devel=None, limit=limit) if binary:
searchresult = owner(apiurl, binary, "binary", usefilter=filterroles, devel=None, limit=limit)
elif opts.user:
searchresult = owner(apiurl, opts.user, "user", usefilter=filterroles, devel=None)
elif opts.group:
searchresult = owner(apiurl, opts.group, "group", usefilter=filterroles, devel=None)
else:
raise oscerr.WrongArgs('osc bug, no valid search criteria')
if opts.add: if opts.add:
if searchresult: if searchresult:
@ -6916,7 +6935,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
metaroot = ET.fromstring(''.join(m)) metaroot = ET.fromstring(''.join(m))
else: else:
# fallback to project lookup for old servers # fallback to project lookup for old servers
if not searchresult: if prj and not searchresult:
m = show_project_meta(apiurl, prj) m = show_project_meta(apiurl, prj)
metaroot = ET.fromstring(''.join(m)) metaroot = ET.fromstring(''.join(m))
@ -6950,38 +6969,40 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print "Defined in package: %s/%s " %(definingproject, definingpackage) print "Defined in package: %s/%s " %(definingproject, definingpackage)
else: else:
print "Defined in project: ", definingproject print "Defined in project: ", definingproject
for role in roles: if prj:
if opts.bugowner and not len(maintainers.get(role, [])): # not for user/group search
role = 'maintainer' for role in roles:
if pac: if opts.bugowner and not len(maintainers.get(role, [])):
print "%s%s of %s/%s : " %(indent, role, prj, pac) role = 'maintainer'
else: if pac:
print "%s%s of %s : " %(indent, role, prj) print "%s%s of %s/%s : " %(indent, role, prj, pac)
if opts.email: else:
emails = [] print "%s%s of %s : " %(indent, role, prj)
for maintainer in maintainers.get(role, []): if opts.email:
user = get_user_data(apiurl, maintainer, 'email') emails = []
if len(user): for maintainer in maintainers.get(role, []):
emails.append(''.join(user)) user = get_user_data(apiurl, maintainer, 'email')
print indent, if len(user):
print ', '.join(emails) or '-' emails.append(''.join(user))
elif opts.verbose:
userdata = []
for maintainer in maintainers.get(role, []):
user = get_user_data(apiurl, maintainer, 'login', 'realname', 'email')
userdata.append(user[0])
if user[1] != '-':
userdata.append("%s <%s>"%(user[1], user[2]))
else:
userdata.append(user[2])
for row in build_table(2, userdata, None, 3):
print indent, print indent,
print row print ', '.join(emails) or '-'
else: elif opts.verbose:
print indent, userdata = []
print ', '.join(maintainers.get(role, [])) or '-' for maintainer in maintainers.get(role, []):
print user = get_user_data(apiurl, maintainer, 'login', 'realname', 'email')
userdata.append(user[0])
if user[1] != '-':
userdata.append("%s <%s>"%(user[1], user[2]))
else:
userdata.append(user[2])
for row in build_table(2, userdata, None, 3):
print indent,
print row
else:
print indent,
print ', '.join(maintainers.get(role, [])) or '-'
print
@cmdln.alias('who') @cmdln.alias('who')
@cmdln.alias('user') @cmdln.alias('user')

View File

@ -5735,12 +5735,12 @@ def search(apiurl, **kwargs):
res[urlpath] = ET.parse(f).getroot() res[urlpath] = ET.parse(f).getroot()
return res return res
def owner(apiurl, binary, attribute=None, project=None, usefilter=None, devel=None, limit=None): def owner(apiurl, binary, mode="binary", attribute=None, project=None, usefilter=None, devel=None, limit=None):
""" """
Perform a binary package owner search. This is supported since OBS 2.4. Perform a binary package owner search. This is supported since OBS 2.4.
""" """
# find default project, if not specified # find default project, if not specified
query = { 'binary': binary } query = { mode: binary }
if attribute: if attribute:
query['attribute'] = attribute query['attribute'] = attribute
if project: if project: