Skip to content

Commit

Permalink
undelete: Migrate to pop_project_package_from_args()
Browse files Browse the repository at this point in the history
INCOMPATIBLE CHANGE:
It is no longer possible to specify multiple packages at once,
because it was inconsistent with the rest of osc.
Call osc in a cycle to undelete multiple packages instead.
  • Loading branch information
dmach committed Jan 12, 2023
1 parent 55fd776 commit be2c33d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
20 changes: 20 additions & 0 deletions behave/features/undelete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: `osc undelete` command


# common steps for all scenarios
Background:
Given I set working directory to "{context.osc.temp}"


@destructive
Scenario: Run `osc undelete <project>/<package>`
Given I execute osc with args "rdelete test:factory/test-pkgA -m 'why:delete'"
When I execute osc with args "undelete test:factory/test-pkgA -m 'why:undelete'"
Then the exit code is 0


@destructive
Scenario: Run `osc undelete <project>`
Given I execute osc with args "rdelete test:factory --recursive -m 'why:delete'"
When I execute osc with args "undelete test:factory -m 'why:undelete'"
Then the exit code is 0
28 changes: 11 additions & 17 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3775,28 +3775,22 @@ def do_undelete(self, subcmd, opts, *args):
usage:
osc undelete PROJECT
osc undelete PROJECT PACKAGE [PACKAGE ...]
osc undelete PROJECT PACKAGE
"""
apiurl = self.get_api_url()

args = slash_split(args)
if len(args) < 1:
raise oscerr.WrongArgs('Missing argument.')

msg = ''
if opts.message:
msg = opts.message
else:
msg = edit_message()
args = list(args)
project, package = pop_project_package_from_args(
args, package_is_optional=True
)
ensure_no_remaining_args(args)

apiurl = self.get_api_url()
prj = self._process_project_name(args[0])
pkgs = args[1:]
msg = opts.message or edit_message()

if pkgs:
for pkg in pkgs:
undelete_package(apiurl, prj, pkg, msg)
if package:
undelete_package(apiurl, project, package, msg)
else:
undelete_project(apiurl, prj, msg)
undelete_project(apiurl, project, msg)

@cmdln.option('-r', '--recursive', action='store_true',
help='deletes a project with packages inside')
Expand Down

0 comments on commit be2c33d

Please sign in to comment.