Split unselect from osc-staging.py to separate file and fix add_review to not bother with review if the sr is already dead. Fixes progress issue#1781.

This commit is contained in:
Tomáš Chvátal 2014-03-24 14:46:50 +01:00
parent ea8042869f
commit 9564484580
3 changed files with 28 additions and 6 deletions

View File

@ -111,10 +111,7 @@ def do_staging(self, subcmd, opts, *args):
elif cmd == 'accept':
return AcceptCommand(api).perform(api. prj_from_letter(args[1]))
elif cmd == 'unselect':
for rq, rq_prj in RequestFinder.find_staged_sr(args[1:], opts.apiurl, api).items():
print('Unselecting "{}" from "{}"'.format(rq, rq_prj['staging']))
api.rm_from_prj(rq_prj['staging'], request_id=rq)
api.add_review(rq, by_group='factory-staging', msg='Please recheck')
return UnselectCommand(api).perform(args[1:])
elif cmd == 'select':
tprj = api.prj_from_letter(args[1])
return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_)

View File

@ -843,6 +843,10 @@ class StagingAPI(object):
if by_group and i.by_group == by_group and i.state == 'new':
return
# don't try to change reviews if the request is dead
if not req.state.name in ['new', 'review']:
return
query = {}
if by_project:
query['by_project'] = by_project

View File

@ -0,0 +1,21 @@
from osc import oscerr
from osc.core import http_GET
from osclib.request_finder import RequestFinder
class UnselectCommand(object):
def __init__(self, api):
self.api = api
def perform(self, packages):
"""
Remove request from staging project
:param packages: packages/requests to delete from staging projects
"""
for request, request_project in RequestFinder.find_staged_sr(packages, opts.apiurl, api).items():
staging_project = request_project['staging']
print('Unselecting "{}" from "{}"'.format(request, staging_project))
self.api.rm_from_prj(staging_project, request_id=request)
self.api.add_review(request, by_group='factory-staging', msg='Please recheck')