Skip to content

Commit

Permalink
Supersede existing requests if --yes is passed to "osc sr"
Browse files Browse the repository at this point in the history
This basically reverts commit b2b59ca, because the old code performed
a "no" instead of a "yes" (see also the discussion in
#269).

Fixes: #343 ("'osc sr --yes ...' doesn't supersede existing requests
       as promised")
  • Loading branch information
marcus-h committed Oct 6, 2017
1 parent aea395a commit 760d4d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,17 +1359,19 @@ def _check_service(root):
return
supersede_existing = False
reqs = []
if not opts.supersede and not opts.yes:
if not opts.supersede:
(supersede_existing, reqs) = check_existing_requests(apiurl,
src_project,
src_package,
dst_project,
dst_package)
dst_package,
not opts.yes)
if not supersede_existing:
(supersede_existing, reqs) = check_existing_maintenance_requests(apiurl,
src_project,
[src_package],
dst_project, None)
dst_project, None,
not opts.yes)
if not opts.message:
difflines = []
doappend = False
Expand Down
8 changes: 6 additions & 2 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4445,11 +4445,13 @@ def get_request_log(apiurl, reqid):
return data

def check_existing_requests(apiurl, src_project, src_package, dst_project,
dst_package):
dst_package, ask=True):
reqs = get_exact_request_list(apiurl, src_project, dst_project,
src_package, dst_package,
req_type='submit',
req_state=['new', 'review', 'declined'])
if not ask:
return True, reqs
repl = ''
if reqs:
print('There are already the following submit request: %s.' % \
Expand All @@ -4464,13 +4466,15 @@ def check_existing_requests(apiurl, src_project, src_package, dst_project,
return repl == 'y', reqs

def check_existing_maintenance_requests(apiurl, src_project, src_packages, dst_project,
release_project):
release_project, ask=True):
reqs = []
for src_package in src_packages:
reqs += get_exact_request_list(apiurl, src_project, dst_project,
src_package, None,
req_type='maintenance_incident',
req_state=['new', 'review', 'declined'])
if not ask:
return True, reqs
repl = ''
if reqs:
print('There are already the following maintenance incident request: %s.' % \
Expand Down

0 comments on commit 760d4d6

Please sign in to comment.