From b38dd0191fd2afa123b266f2f0109fa798d73055 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Fri, 27 Apr 2012 15:04:06 +0200 Subject: [PATCH] - request_interactive_review: automatically accept/decline a review for a specific group (if a group was specified) To enable this feature set the newly introduced "review_inherit_group" config option to True. --- osc/commandline.py | 2 +- osc/conf.py | 11 +++++++++-- osc/core.py | 35 ++++++++++++++++++++--------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 14430e55..86a0997d 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2033,7 +2033,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. for result in results: if days == 0 or result.state.when > since or result.state.name == 'new': if (opts.interactive or conf.config['request_show_interactive']) and not opts.non_interactive: - request_interactive_review(apiurl, result) + request_interactive_review(apiurl, result, group=opts.group) else: print result.list_view(), '\n' else: diff --git a/osc/conf.py b/osc/conf.py index 7ffdf73c..422899c6 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -142,6 +142,9 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org', # what to do with the source package if the submitrequest has been accepted 'submitrequest_on_accept_action': '', 'request_show_interactive': '0', + # if a review is accepted in interactive mode and a group + # was specified the review will be accepted for this group + 'review_inherit_group': '0', 'submitrequest_accepted_template': '', 'submitrequest_declined_template': '', 'linkcontrol': '0', @@ -161,8 +164,8 @@ config = DEFAULTS.copy() boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd', 'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive', - 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug', 'include_request_from_project', - 'local_service_run'] + 'review_inherit_group', 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug', + 'include_request_from_project', 'local_service_run'] api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj'] @@ -305,6 +308,10 @@ apiurl = %(apiurl)s #review requests interactively (default: off) #request_show_review = 1 +# if a review is accepted in interactive mode and a group +# was specified the review will be accepted for this group (default: off) +#review_inherit_group = 1 + [%(apiurl)s] user = %(user)s pass = %(pass)s diff --git a/osc/core.py b/osc/core.py index d969f7a3..3ea246c2 100644 --- a/osc/core.py +++ b/osc/core.py @@ -6118,7 +6118,7 @@ def print_request_list(apiurl, project, package = None, states = ('new','review' for r in requests: print r.list_view(), '\n' -def request_interactive_review(apiurl, request, initial_cmd=''): +def request_interactive_review(apiurl, request, initial_cmd='', group=None): """review the request interactively""" import tempfile, re @@ -6224,20 +6224,25 @@ def request_interactive_review(apiurl, request, initial_cmd=''): if not reviews: change_request_state(apiurl, request.reqid, state, msg) break - print 'Please chose one of the following reviews:' - for i in range(len(reviews)): - fmt = Request.format_review(reviews[i]) - print '(%i)' % i, 'by %(type)-10s %(by)s' % fmt - num = raw_input('> ') - try: - num = int(num) - except ValueError: - print '\'%s\' is not a number.' % num - continue - if num < 0 or num >= len(reviews): - print 'number \'%s\' out of range.' % num - continue - review = reviews[num] + group_reviews = [r for r in reviews if (r.by_group is not None + and r.by_group == group)] + if len(group_reviews) == 1 and conf.config['review_inherit_group']: + review = group_reviews[0] + else: + print 'Please chose one of the following reviews:' + for i in range(len(reviews)): + fmt = Request.format_review(reviews[i]) + print '(%i)' % i, 'by %(type)-10s %(by)s' % fmt + num = raw_input('> ') + try: + num = int(num) + except ValueError: + print '\'%s\' is not a number.' % num + continue + if num < 0 or num >= len(reviews): + print 'number \'%s\' out of range.' % num + continue + review = reviews[num] change_review_state(apiurl, request.reqid, state, by_user=review.by_user, by_group=review.by_group, by_project=review.by_project, by_package=review.by_package, message=msg)