From 147719369480754fb98aab14b2f78f84ddd0822d Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 18 Aug 2010 11:42:50 +0200 Subject: [PATCH] added 'osc reqmaintainership' Added 'osc reqmaintainership' as shortcut for 'osc creq -a add_role USER maintainer PROJECT PACKAGE' since this command is hard to find for (new) users. Works also from checked out packages. If no user is specified, the command takes the current osc user from the config. --- osc/commandline.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index 72df72ef..63948146 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1348,6 +1348,65 @@ Please submit there instead, or use --nodevelproject to force direct submission. return root.get('id') + @cmdln.option('-m', '--message', metavar='TEXT', + help='specify message TEXT') + @cmdln.alias("reqmaintainership") + @cmdln.alias("reqms") + def do_requestmaintainership(self, subcmd, opts, *args): + """${cmd_name}: requests to add user as maintainer + + usage: + osc requestmaintainership # for current user in checked out package + osc requestmaintainership USER # for specified user in checked out package + osc requestmaintainership PROJECT PACKAGE # for current user + osc requestmaintainership PROJECT PACKAGE USER # request for specified user + + ${cmd_option_list} + """ + args = slash_split(args) + apiurl = self.get_api_url() + + if len(args) < 2: + if is_package_dir(os.getcwd()): + project = store_read_project(os.curdir) + package = store_read_package(os.curdir) + if len(args) == 0: + user = conf.config['user'] + else: + user = args[0] + else: + raise oscerr.WrongArgs('Wrong number of arguments. 1') + elif len(args) == 2: + project = args[0] + package = args[1] + user = conf.config['user'] + elif len(args) == 3: + project = args[0] + package = args[1] + user = args[2] + else: + raise oscerr.WrongArgs('Wrong number of arguments. 2') + + arg = [ user, 'maintainer', project, package ] + + actionsxml = "" + actionsxml += self._add_role(arg, None) + + if actionsxml == "": + sys.exit('No actions need to be taken.') + + if not opts.message: + opts.message = edit_message() + + import cgi + xml = """ %s %s """ % \ + (actionsxml, cgi.escape(opts.message or "")) + u = makeurl(apiurl, ['request'], query='cmd=create') + f = http_POST(u, data=xml) + + root = ET.parse(f).getroot() + return root.get('id') + @cmdln.option('-m', '--message', metavar='TEXT', help='specify message TEXT') @cmdln.alias("dr")