1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-03 21:36:15 +01:00

Merge pull request #1479 from dmach/branch-scmsync

Error out when branching a scmsync package
This commit is contained in:
Daniel Mach 2024-02-09 14:30:31 +01:00 committed by GitHub
commit ff31a5cd4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View File

@ -172,7 +172,7 @@ def run(prg, argv=None):
print(e.msg, file=sys.stderr)
traceback.print_exc(file=sys.stderr)
except oscerr.PackageError as e:
print(e.msg, file=sys.stderr)
print(str(e), file=sys.stderr)
except PackageError as e:
print(f'{e.fname}:', e.msg, file=sys.stderr)
except RPMError as e:

View File

@ -6133,6 +6133,34 @@ def branch_pkg(
"""
Branch a package (via API call)
"""
# BEGIN: Error out on branching scmsync packages; this should be properly handled in the API
# read src_package meta
m = b"".join(show_package_meta(apiurl, src_project, src_package))
root = ET.fromstring(m)
devel_project = None
devel_package = None
if not nodevelproject:
devel_node = root.find("devel")
if devel_node is not None:
devel_project = devel_node.get("project")
devel_package = devel_node.get("package", src_package)
if devel_project:
# replace src_package meta with devel_package meta because we're about branch from devel
m = b"".join(show_package_meta(apiurl, devel_project, devel_package))
root = ET.fromstring(m)
# error out if we're branching a scmsync package (we'd end up with garbage anyway)
if root.find("scmsync") is not None:
msg = "Cannot branch a package with <scmsync> set."
if devel_project:
raise oscerr.PackageError(devel_project, devel_package, msg)
raise oscerr.PackageError(src_project, src_package, msg)
# END: Error out on branching scmsync packages; this should be properly handled in the API
query = {'cmd': 'branch'}
if nodevelproject:
query['ignoredevel'] = '1'