action #1784 Unselect do not need a Project parameter, only the Package
This commit is contained in:
parent
f84a67316e
commit
5cdde68c8b
@ -187,8 +187,10 @@ def do_staging(self, subcmd, opts, *args):
|
|||||||
min_args, max_args = 1, 1
|
min_args, max_args = 1, 1
|
||||||
elif cmd == 'check':
|
elif cmd == 'check':
|
||||||
min_args, max_args = 0, 2
|
min_args, max_args = 0, 2
|
||||||
elif cmd in ('select', 'unselect'):
|
elif cmd == 'select':
|
||||||
min_args, max_args = 2, None
|
min_args, max_args = 2, None
|
||||||
|
elif cmd == 'unselect':
|
||||||
|
min_args, max_args = 1, None
|
||||||
elif cmd in ('list', 'cleanup_rings'):
|
elif cmd in ('list', 'cleanup_rings'):
|
||||||
min_args, max_args = 0, 0
|
min_args, max_args = 0, 0
|
||||||
else:
|
else:
|
||||||
@ -258,11 +260,15 @@ def do_staging(self, subcmd, opts, *args):
|
|||||||
elif cmd == 'accept':
|
elif cmd == 'accept':
|
||||||
return AcceptCommand(api).perform(api. prj_from_letter(args[1]), opts.commit)
|
return AcceptCommand(api).perform(api. prj_from_letter(args[1]), opts.commit)
|
||||||
elif cmd == 'unselect':
|
elif cmd == 'unselect':
|
||||||
tprj = api.prj_from_letter(args[1]) # see issue 1784
|
for rq_or_pkg in args[1:]:
|
||||||
for rq, rq_prj in RequestFinder.find_sr(args[2:], opts.apiurl).items():
|
rq, rq_prj = RequestFinder.find_single_sr(rq_or_pkg, opts.apiurl)
|
||||||
api.rm_from_prj(tprj, request_id=rq)
|
if 'staging' in rq_prj:
|
||||||
|
print('Unselecting "{}" from "{}"'.format(rq_or_pkg, rq_prj['staging']))
|
||||||
|
api.rm_from_prj(rq_prj['staging'], request_id=rq)
|
||||||
api.add_review(rq, by_group='factory-staging',
|
api.add_review(rq, by_group='factory-staging',
|
||||||
msg='Please recheck')
|
msg='Please recheck')
|
||||||
|
else:
|
||||||
|
print('Can\'t unselect "{}" because is not in any staging project'.format(rq_or_pkg))
|
||||||
elif cmd == 'select':
|
elif cmd == 'select':
|
||||||
tprj = api.prj_from_letter(args[1])
|
tprj = api.prj_from_letter(args[1])
|
||||||
return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_)
|
return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_)
|
||||||
|
@ -121,10 +121,12 @@ class RequestFinder:
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def find(self, pkgs):
|
def find(self, pkgs, include_project=True):
|
||||||
"""
|
"""
|
||||||
Search for all various mutations and return list of SR#s
|
Search for all various mutations and return list of SR#s
|
||||||
:param pkgs: mesh of argumets to search for
|
:param pkgs: mesh of argumets to search for
|
||||||
|
:param include_project: if True, include the search or request
|
||||||
|
inside a project
|
||||||
|
|
||||||
This function is only called for its side effect.
|
This function is only called for its side effect.
|
||||||
"""
|
"""
|
||||||
@ -147,3 +149,15 @@ class RequestFinder:
|
|||||||
finder = cls(apiurl)
|
finder = cls(apiurl)
|
||||||
finder.find(pkgs)
|
finder.find(pkgs)
|
||||||
return finder.srs
|
return finder.srs
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def find_single_sr(cls, pkg, apiurl):
|
||||||
|
"""
|
||||||
|
Search for all various mutations and return a single SR#s.
|
||||||
|
:param pkg: a single SR|package to search
|
||||||
|
:param apiurl: OBS url
|
||||||
|
"""
|
||||||
|
finder = cls(apiurl)
|
||||||
|
finder.find([pkg], include_project=False)
|
||||||
|
assert len(finder.srs) <= 1, 'Found more that one submit request'
|
||||||
|
return finder.srs.items()[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user