Skip to content

Commit

Permalink
fix branch -N
Browse files Browse the repository at this point in the history
Branching with missingok must not ask for existing package, it
will lead to an error
  • Loading branch information
adrianschroeter committed Apr 3, 2024
1 parent 1bf2264 commit 68e8ff4
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6106,27 +6106,28 @@ def branch_pkg(
# 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)
if not missingok:
m = b"".join(show_package_meta(apiurl, src_project, src_package))
root = ET.fromstring(m)

Check warning on line 6114 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L6111-L6114

Added lines #L6111 - L6114 were not covered by tests
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

Check warning on line 6121 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L6116-L6121

Added lines #L6116 - L6121 were not covered by tests
m = b"".join(show_package_meta(apiurl, devel_project, devel_package))
root = ET.fromstring(m)

Check warning on line 6124 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L6123-L6124

Added lines #L6123 - L6124 were not covered by tests
# 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)

Check warning on line 6130 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L6127-L6130

Added lines #L6127 - L6130 were not covered by tests

# END: Error out on branching scmsync packages; this should be properly handled in the API

Expand Down

0 comments on commit 68e8ff4

Please sign in to comment.