Skip to content

Commit

Permalink
"maintainer --user" support to search for all official maintained ins…
Browse files Browse the repository at this point in the history
…tance for given user or group
  • Loading branch information
adrianschroeter committed Feb 20, 2013
1 parent f0d1acf commit 220ec0e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 39 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
95 changes: 58 additions & 37 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=[],
Expand All @@ -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 <options>
# Search for official maintained sources in OBS instance
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 PKG <options>
Expand All @@ -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:
Expand All @@ -6822,15 +6834,22 @@ 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
filterroles=roles
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:
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 220ec0e

Please sign in to comment.