diff --git a/NEWS b/NEWS index 6f57acc580..609f141056 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ - support generic emulator virtualization - added "--host" argument to "osc build" (used to perform the build on a remote host) - "search --maintained" is obsolete. Abort on usage. + - "maintainer --user" support to search for all official maintained instance for given user or group 0.138 - add support to remove repositories recursively (mostly only usefull for admins) diff --git a/osc/commandline.py b/osc/commandline.py index d96a85679a..1521ea3467 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6111,7 +6111,7 @@ def do_my(self, subcmd, opts, *args): """${cmd_name}: show waiting work, packages, projects or requests involving yourself Examples: - # list all tasks where it is expected to work on + # list all open tasks for me osc ${cmd_name} [work] # list packages where I am bugowner osc ${cmd_name} pkg -b @@ -6769,6 +6769,10 @@ def do_api(self, subcmd, opts, url): help='Set the bugowner to specified person') @cmdln.option('-S', '--set-bugowner-request', metavar='user', 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', help='delete a maintainer/bugowner (can be specified via --role)') @cmdln.option('-r', '--role', metavar='role', action='append', default=[], @@ -6777,8 +6781,13 @@ def do_api(self, subcmd, opts, url): def do_maintainer(self, subcmd, opts, *args): """${cmd_name}: Show maintainers of a project/package - osc maintainer + # Search for official maintained sources in OBS instance osc maintainer BINARY + osc maintainer -U + osc maintainer -G + + # Lookup in specific containers + osc maintainer osc maintainer PRJ osc maintainer PRJ PKG @@ -6804,7 +6813,10 @@ def do_maintainer(self, subcmd, opts, *args): roles = [ 'bugowner' ] 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: pac = store_read_package('.') except oscerr.NoWorkingCopy: @@ -6822,7 +6834,7 @@ def do_maintainer(self, subcmd, opts, *args): apiurl = self.get_api_url() # Try the OBS 2.4 way first. - if pac==None and binary: + if binary or opts.user or opts.group: limit=None if opts.all: limit=0 @@ -6830,7 +6842,14 @@ def do_maintainer(self, subcmd, opts, *args): if filterroles == [ 'bugowner', 'maintainer' ]: # use server side configured default 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 searchresult: @@ -6916,7 +6935,7 @@ def do_maintainer(self, subcmd, opts, *args): metaroot = ET.fromstring(''.join(m)) else: # fallback to project lookup for old servers - if not searchresult: + if prj and not searchresult: m = show_project_meta(apiurl, prj) metaroot = ET.fromstring(''.join(m)) @@ -6950,38 +6969,40 @@ def do_maintainer(self, subcmd, opts, *args): print "Defined in package: %s/%s " %(definingproject, definingpackage) else: print "Defined in project: ", definingproject - - for role in roles: - if opts.bugowner and not len(maintainers.get(role, [])): - role = 'maintainer' - if pac: - print "%s%s of %s/%s : " %(indent, role, prj, pac) - else: - print "%s%s of %s : " %(indent, role, prj) - if opts.email: - emails = [] - for maintainer in maintainers.get(role, []): - user = get_user_data(apiurl, maintainer, 'email') - if len(user): - emails.append(''.join(user)) - print indent, - print ', '.join(emails) or '-' - 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): + + if prj: + # not for user/group search + for role in roles: + if opts.bugowner and not len(maintainers.get(role, [])): + role = 'maintainer' + if pac: + print "%s%s of %s/%s : " %(indent, role, prj, pac) + else: + print "%s%s of %s : " %(indent, role, prj) + if opts.email: + emails = [] + for maintainer in maintainers.get(role, []): + user = get_user_data(apiurl, maintainer, 'email') + if len(user): + emails.append(''.join(user)) print indent, - print row - else: - print indent, - print ', '.join(maintainers.get(role, [])) or '-' - print + print ', '.join(emails) or '-' + 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 row + else: + print indent, + print ', '.join(maintainers.get(role, [])) or '-' + print @cmdln.alias('who') @cmdln.alias('user') diff --git a/osc/core.py b/osc/core.py index 6e24c8f4bf..8507b6a00f 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5735,12 +5735,12 @@ def search(apiurl, **kwargs): res[urlpath] = ET.parse(f).getroot() 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. """ # find default project, if not specified - query = { 'binary': binary } + query = { mode: binary } if attribute: query['attribute'] = attribute if project: