- handle build disable in select command just like comment instead of stagingapi move_between_project() for consistency and to reduce double checking the same information via extra API calls - build_switch_staging_project() provides target_flag parameter rather than trying to figure out flag value since caller has the context to know and again reduces API calls - build_switch_staging_project() checking conditions are essentially checking if True is True since non-adi projects will always have ring packages or rings disabled entirely. The condition of interest is non-empty. Additionally adi projects are removed if empty so not a terribly useful distinction to make. - provide helper update_status_or_deactivate() to handle common logic and replace in calling locations
40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
from osc.core import get_request
|
|
from osclib.request_finder import RequestFinder
|
|
|
|
|
|
class UnselectCommand(object):
|
|
|
|
def __init__(self, api):
|
|
self.api = api
|
|
|
|
def perform(self, packages, cleanup=False):
|
|
"""
|
|
Remove request from staging project
|
|
:param packages: packages/requests to delete from staging projects
|
|
"""
|
|
|
|
if cleanup:
|
|
obsolete = self.api.project_status_requests('obsolete')
|
|
if len(obsolete) > 0:
|
|
print('Cleanup {} obsolete requests'.format(len(obsolete)))
|
|
packages += tuple(obsolete)
|
|
|
|
ignored_requests = self.api.get_ignored_requests()
|
|
affected_projects = set()
|
|
for request, request_project in RequestFinder.find_staged_sr(packages,
|
|
self.api).items():
|
|
staging_project = request_project['staging']
|
|
affected_projects.add(staging_project)
|
|
msg = 'Unselecting "{}" from "{}"'.format(request, staging_project)
|
|
print(msg)
|
|
self.api.rm_from_prj(staging_project, request_id=request, msg='Removing from {}, re-evaluation needed'.format(staging_project))
|
|
self.api.add_review(request, by_group=self.api.cstaging_group, msg='Requesting new staging review')
|
|
|
|
req = get_request(self.api.apiurl, str(request))
|
|
if req.state.name in ('new', 'review') and request not in ignored_requests:
|
|
print(' Consider marking the request ignored to let others know not to restage.')
|
|
|
|
# Notify everybody about the changes
|
|
for prj in affected_projects:
|
|
self.api.update_status_or_deactivate(prj, 'unselect')
|