1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-22 14:38:53 +02:00

linkpac: Improve command-line handling

This commit is contained in:
2022-12-20 16:57:36 +01:00
parent ce4cd4e4e9
commit 1b034921c8
2 changed files with 24 additions and 28 deletions

View File

@@ -3037,10 +3037,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
A linked package is a clone of another package, but plus local A linked package is a clone of another package, but plus local
modifications. It can be cross-project. modifications. It can be cross-project.
The DESTPAC name is optional; the source packages' name will be used if The TARGET_PACKAGE name is optional; the source packages' name will be used if
DESTPAC is omitted. TARGET_PACKAGE is omitted.
Afterwards, you will want to 'checkout DESTPRJ DESTPAC'. Afterwards, you will want to 'checkout TARGET_PROJECT TARGET_PACKAGE'.
To add a patch, add the patch as file and add it to the _link file. To add a patch, add the patch as file and add it to the _link file.
You can also specify text which will be inserted at the top of the spec file. You can also specify text which will be inserted at the top of the spec file.
@@ -3052,30 +3052,24 @@ Please submit there instead, or use --nodevelproject to force direct submission.
will be cleaned up automatically after it was submitted back. will be cleaned up automatically after it was submitted back.
usage: usage:
osc linkpac SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC] osc linkpac PROJECT PACKAGE TARGET_PROJECT [TARGET_PACKAGE]
osc linkpac TARGET_PROJECT [TARGET_PACKAGE] # from a package checkout
""" """
args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
if not args or len(args) < 3: args = list(args)
self.argparse_error("Incorrect number of arguments.") 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 tgt_package:
tgt_package = src_package
rev, dummy = parseRevisionOption(opts.revision) rev, dummy = parseRevisionOption(opts.revision)
vrev = None vrev = None
src_project = self._process_project_name(args[0]) if src_project == tgt_project and not opts.cicount:
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.')
if src_project == dst_project and not opts.cicount:
# in this case, the user usually wants to build different spec # in this case, the user usually wants to build different spec
# files from the same source # files from the same source
opts.cicount = "copy" opts.cicount = "copy"
@@ -3086,12 +3080,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# vrev is only needed for srcmd5 and OBS instances < 2.1.17 do not support it # vrev is only needed for srcmd5 and OBS instances < 2.1.17 do not support it
vrev = None vrev = None
if rev and not checkRevision(src_project, src_package, rev):
print('Revision \'%s\' does not exist' % rev, file=sys.stderr)
sys.exit(1)
link_pac( link_pac(
src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount, src_project, src_package, tgt_project, tgt_package, opts.force, rev, opts.cicount,
opts.disable_publish, opts.new_package, vrev, opts.disable_publish, opts.new_package, vrev,
disable_build=opts.disable_build, disable_build=opts.disable_build,
) )

View File

@@ -5497,11 +5497,11 @@ def link_pac(
dst_project: str, dst_project: str,
dst_package: str, dst_package: str,
force: bool, force: bool,
rev="", rev=None,
cicount="", cicount=None,
disable_publish=False, disable_publish=False,
missing_target=False, missing_target=False,
vrev="", vrev=None,
disable_build=False, disable_build=False,
): ):
""" """
@@ -5509,6 +5509,12 @@ def link_pac(
- "src" is the original package - "src" is the original package
- "dst" is the "link" package that we are creating here - "dst" is the "link" package that we are creating here
""" """
if src_project == dst_project and src_package == dst_package:
raise oscerr.OscValueError("Cannot link package. Source and target are the same.")
if rev and not checkRevision(src_project, src_package, rev):
raise oscerr.OscValueError(f"Revision doesn't exist: {rev}")
meta_change = False meta_change = False
dst_meta = '' dst_meta = ''
apiurl = conf.config['apiurl'] apiurl = conf.config['apiurl']