1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-07 13:48:43 +02:00

add --role option to maintainer command

This commit is contained in:
2009-06-19 13:57:27 +00:00
parent c76ac4dd5e
commit 87067cd0aa
3 changed files with 14 additions and 5 deletions

View File

@@ -2951,6 +2951,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='add a new maintainer')
@cmdln.option('-d', '--delete', metavar='user',
help='delete a maintainer from a project or package')
@cmdln.option('-r', '--role', metavar='role',
help='Specify user role')
def do_maintainer(self, subcmd, opts, *args):
"""${cmd_name}: Show maintainers of a project/package
@@ -2967,6 +2969,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
maintainers = []
pac = None
tree = None
role = opts.role
roles = [ 'bugowner', 'maintainer' ]
if opts.bugowner:
roles = [ 'bugowner' ]
@@ -2996,9 +2999,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('I need at least one argument.')
if opts.add:
addMaintainer(conf.config['apiurl'], prj, pac, opts.add)
addPerson(conf.config['apiurl'], prj, pac, opts.add, role)
elif opts.delete:
delMaintainer(conf.config['apiurl'], prj, pac, opts.delete)
delPerson(conf.config['apiurl'], prj, pac, opts.delete, role)
elif opts.devel_project:
setDevelProject(conf.config['apiurl'], prj, pac, opts.devel_project)
else:

View File

@@ -3648,7 +3648,11 @@ def is_srcrpm(f):
return False
def addMaintainer(apiurl, prj, pac, user):
""" add a new maintainer to a package or project """
# for backward compatibility only
addPerson(apiurl, prj, pac, user)
def addPerson(apiurl, prj, pac, user, role="maintainer"):
""" add a new person to a package or project """
path = quote_plus(prj),
kind = 'prj'
if pac:
@@ -3663,13 +3667,13 @@ def addMaintainer(apiurl, prj, pac, user):
tree = ET.fromstring(''.join(data))
found = False
for person in tree.getiterator('person'):
if person.get('userid') == user:
if person.get('userid') == user and person.get('role') == role:
found = True
print "user already exists"
break
if not found:
# the xml has a fixed structure
tree.insert(2, ET.Element('person', role='maintainer', userid=user))
tree.insert(2, ET.Element('person', role=role, userid=user))
print 'user \'%s\' added to \'%s\'' % (user, pac or prj)
edit_meta(metatype=kind,
path_args=path,