From be2c33d86fe70874c738483b3a5cc06058329863 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 2 Jan 2023 15:49:58 +0100 Subject: [PATCH] undelete: Migrate to pop_project_package_from_args() 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. --- behave/features/undelete.feature | 20 ++++++++++++++++++++ osc/commandline.py | 30 ++++++++++++------------------ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 behave/features/undelete.feature diff --git a/behave/features/undelete.feature b/behave/features/undelete.feature new file mode 100644 index 00000000..f8a215a5 --- /dev/null +++ b/behave/features/undelete.feature @@ -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 /` + 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 ` + 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 diff --git a/osc/commandline.py b/osc/commandline.py index 9a3d3f59..3792f4b4 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3775,28 +3775,22 @@ Please submit there instead, or use --nodevelproject to force direct submission. usage: osc undelete PROJECT - osc undelete PROJECT PACKAGE [PACKAGE ...] + osc undelete PROJECT PACKAGE """ - - args = slash_split(args) - if len(args) < 1: - raise oscerr.WrongArgs('Missing argument.') - - msg = '' - if opts.message: - msg = opts.message - else: - msg = edit_message() - apiurl = self.get_api_url() - prj = self._process_project_name(args[0]) - pkgs = args[1:] - if pkgs: - for pkg in pkgs: - undelete_package(apiurl, prj, pkg, msg) + args = list(args) + project, package = pop_project_package_from_args( + args, package_is_optional=True + ) + ensure_no_remaining_args(args) + + msg = opts.message or edit_message() + + 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')