diff --git a/behave/features/detachbranch.feature b/behave/features/detachbranch.feature new file mode 100644 index 00000000..102cf137 --- /dev/null +++ b/behave/features/detachbranch.feature @@ -0,0 +1,27 @@ +Feature: `osc detachbranch` command + + +# common steps for all scenarios +Background: + Given I set working directory to "{context.osc.temp}" + And I execute osc with args "linkpac test:factory/test-pkgA home:Admin" + + +@destructive +Scenario: Run `osc detachbranch ` + When I execute osc with args "detachbranch home:Admin test-pkgA" + Then the exit code is 0 + + +@destructive +Scenario: Run `osc detachbranch ` + When I execute osc with args "detachbranch home:Admin" + Then the exit code is 1 + + +@destructive +Scenario: Run `osc detachbranch` from a package working copy + Given I execute osc with args "co home:Admin/test-pkgA" + And I set working directory to "{context.osc.temp}/home:Admin/test-pkgA" + When I execute osc with args "detachbranch" + Then the exit code is 0 diff --git a/osc/commandline.py b/osc/commandline.py index a78f3241..e3a5407d 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2974,21 +2974,16 @@ Please submit there instead, or use --nodevelproject to force direct submission. does not exist anymore. usage: - osc detachbranch # can be used in package working copy + osc detachbranch # from a package working copy osc detachbranch PROJECT PACKAGE """ - args = slash_split(args) apiurl = self.get_api_url() - if len(args) == 0: - project = store_read_project(Path.cwd()) - package = store_read_package(Path.cwd()) - elif len(args) == 2: - project = self._process_project_name(args[0]) - package = args[1] - elif len(args) > 2: - raise oscerr.WrongArgs('Too many arguments (required none or two)') - else: - raise oscerr.WrongArgs('Too few arguments (required none or two)') + + args = list(args) + project, package = pop_project_package_from_args( + args, default_project=".", default_package=".", package_is_optional=False + ) + ensure_no_remaining_args(args) try: copy_pac(apiurl, project, package, apiurl, project, package, expand=True, comment=opts.message)