openSUSE-release-tools/osclib/supersede_command.py
Stephan Kulow 0cef959328 Work around OBS issue 8994
Instead of declining the by_project review, unselect the request and
decline the group review. This way we avoid the OBS problem
2020-03-18 22:40:47 +01:00

30 lines
1.1 KiB
Python

from colorama import Fore
class SupersedeCommand(object):
CODE_MAP = {
None: Fore.MAGENTA + 'superseded' + Fore.RESET,
True: Fore.RED + 'declined' + Fore.RESET,
False: Fore.WHITE + 'ignored' + Fore.RESET,
}
def __init__(self, api):
self.api = api
def perform(self, requests=None):
for stage_info, code, request in self.api.dispatch_open_requests(requests):
action = request.find('action')
target_package = action.find('target').get('package')
if code == 'unstage':
# Technically, the new request has not been staged, but superseded the old one.
code = None
verbage = self.CODE_MAP[code]
if code is not None:
verbage += ' in favor of'
print('request {} for {} {} {} in {}'.format(
request.get('id'),
Fore.CYAN + target_package + Fore.RESET,
verbage,
stage_info['rq_id'],
Fore.YELLOW + stage_info['prj'] + Fore.RESET))