1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 22:56:15 +01:00

aggregatepac: Migrate to pop_project_package_targetproject_targetpackage_from_args()

This commit is contained in:
Daniel Mach 2023-01-02 15:05:35 +01:00
parent d779eb936d
commit fd851bbe83
3 changed files with 34 additions and 15 deletions

View File

@ -0,0 +1,23 @@
Feature: `osc aggregatepac` command
# common steps for all scenarios
Background:
Given I set working directory to "{context.osc.temp}"
@destructive
Scenario: Run `osc aggregatepac <project>/<package> <target-project>`
When I execute osc with args "aggregatepac test:factory/test-pkgA home:Admin"
Then the exit code is 0
@destructive
Scenario: Run `osc aggregatepac <project>/<package> <target-project>/<target-package>`
When I execute osc with args "aggregatepac test:factory/test-pkgA home:Admin/test-pkgAA"
Then the exit code is 0
Scenario: Run `osc aggregatepac` where the source and target are the same
When I execute osc with args "aggregatepac test:factory/test-pkgA test:factory"
Then the exit code is 1

View File

@ -3100,21 +3100,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc aggregatepac SOURCEPRJ SOURCEPAC[:FLAVOR] DESTPRJ [DESTPAC] osc aggregatepac SOURCEPRJ SOURCEPAC[:FLAVOR] DESTPRJ [DESTPAC]
""" """
args = slash_split(args) args = list(args)
src_project, src_package, tgt_project, tgt_package = pop_project_package_targetproject_targetpackage_from_args(
args, target_package_is_optional=True,
)
ensure_no_remaining_args(args)
if not args or len(args) < 3: if not tgt_package:
self.argparse_error("Incorrect number of arguments.") tgt_package = src_package
src_project = self._process_project_name(args[0])
src_package = args[1]
dst_project = self._process_project_name(args[2])
if len(args) > 3:
dst_package = args[3]
else:
dst_package = src_package
if src_project == dst_project and src_package == dst_package:
raise oscerr.WrongArgs('Error: source and destination are the same.')
repo_map = {} repo_map = {}
if opts.map_repo: if opts.map_repo:
@ -3124,7 +3117,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongOptions('map "%s" must be SRC=TARGET[,SRC=TARGET]' % opts.map_repo) raise oscerr.WrongOptions('map "%s" must be SRC=TARGET[,SRC=TARGET]' % opts.map_repo)
repo_map[src_tgt[0]] = src_tgt[1] repo_map[src_tgt[0]] = src_tgt[1]
aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map, opts.disable_publish, opts.nosources) aggregate_pac(src_project, src_package, tgt_project, tgt_package, repo_map, opts.disable_publish, opts.nosources)
@cmdln.option('-c', '--client-side-copy', action='store_true', @cmdln.option('-c', '--client-side-copy', action='store_true',
help='do a (slower) client-side copy') help='do a (slower) client-side copy')

View File

@ -5631,6 +5631,9 @@ def aggregate_pac(
- "map" is a dictionary SRC => TARGET repository mappings - "map" is a dictionary SRC => TARGET repository mappings
- "repo_check" determines if presence of repos in the source and destination repos is checked - "repo_check" determines if presence of repos in the source and destination repos is checked
""" """
if (src_project, src_package) == (dst_project, dst_package):
raise oscerr.OscValueError("Cannot aggregate package. Source and target are the same.")
meta_change = False meta_change = False
dst_meta = '' dst_meta = ''
apiurl = conf.config['apiurl'] apiurl = conf.config['apiurl']