1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 17:16:12 +01:00

- 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.
This commit is contained in:
Marcus Huewe 2012-04-27 15:04:06 +02:00
parent 7ce054b5cc
commit b38dd0191f
3 changed files with 30 additions and 18 deletions

View File

@ -2033,7 +2033,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
for result in results: for result in results:
if days == 0 or result.state.when > since or result.state.name == 'new': 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: 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: else:
print result.list_view(), '\n' print result.list_view(), '\n'
else: else:

View File

@ -142,6 +142,9 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
# what to do with the source package if the submitrequest has been accepted # what to do with the source package if the submitrequest has been accepted
'submitrequest_on_accept_action': '', 'submitrequest_on_accept_action': '',
'request_show_interactive': '0', '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_accepted_template': '',
'submitrequest_declined_template': '', 'submitrequest_declined_template': '',
'linkcontrol': '0', 'linkcontrol': '0',
@ -161,8 +164,8 @@ config = DEFAULTS.copy()
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd', 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', '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', 'review_inherit_group', 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug',
'local_service_run'] 'include_request_from_project', 'local_service_run']
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj'] 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) #review requests interactively (default: off)
#request_show_review = 1 #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] [%(apiurl)s]
user = %(user)s user = %(user)s
pass = %(pass)s pass = %(pass)s

View File

@ -6118,7 +6118,7 @@ def print_request_list(apiurl, project, package = None, states = ('new','review'
for r in requests: for r in requests:
print r.list_view(), '\n' 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""" """review the request interactively"""
import tempfile, re import tempfile, re
@ -6224,20 +6224,25 @@ def request_interactive_review(apiurl, request, initial_cmd=''):
if not reviews: if not reviews:
change_request_state(apiurl, request.reqid, state, msg) change_request_state(apiurl, request.reqid, state, msg)
break break
print 'Please chose one of the following reviews:' group_reviews = [r for r in reviews if (r.by_group is not None
for i in range(len(reviews)): and r.by_group == group)]
fmt = Request.format_review(reviews[i]) if len(group_reviews) == 1 and conf.config['review_inherit_group']:
print '(%i)' % i, 'by %(type)-10s %(by)s' % fmt review = group_reviews[0]
num = raw_input('> ') else:
try: print 'Please chose one of the following reviews:'
num = int(num) for i in range(len(reviews)):
except ValueError: fmt = Request.format_review(reviews[i])
print '\'%s\' is not a number.' % num print '(%i)' % i, 'by %(type)-10s %(by)s' % fmt
continue num = raw_input('> ')
if num < 0 or num >= len(reviews): try:
print 'number \'%s\' out of range.' % num num = int(num)
continue except ValueError:
review = reviews[num] 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, change_review_state(apiurl, request.reqid, state, by_user=review.by_user,
by_group=review.by_group, by_project=review.by_project, by_group=review.by_group, by_project=review.by_project,
by_package=review.by_package, message=msg) by_package=review.by_package, message=msg)