Skip to content

Commit

Permalink
Migrate core.set_devel_project() to obs_api.Package
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Feb 13, 2024
1 parent 61dd9c0 commit 3a6af40
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3876,6 +3876,8 @@ def show_devel_project(apiurl, prj, pac):


def set_devel_project(apiurl, prj, pac, devprj=None, devpac=None, print_to="debug"):
from . import obs_api

Check warning on line 3879 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3879

Added line #L3879 was not covered by tests

if devprj:
msg = "Setting devel project of"
else:
Expand All @@ -3890,26 +3892,18 @@ def set_devel_project(apiurl, prj, pac, devprj=None, devpac=None, print_to="debu
)
_private.print_msg(msg, print_to=print_to)

meta = show_package_meta(apiurl, prj, pac)
root = ET.fromstring(b''.join(meta))
node = root.find('devel')
if node is None:
if devprj is None:
return
node = ET.Element('devel')
root.append(node)
package_obj = obs_api.Package.from_api(apiurl, prj, pac)

Check warning on line 3895 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3895

Added line #L3895 was not covered by tests

if devprj is None:
package_obj.devel = None

Check warning on line 3898 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3897-L3898

Added lines #L3897 - L3898 were not covered by tests
else:
if devprj is None:
root.remove(node)
else:
node.clear()
if devprj:
node.set('project', devprj)
if devpac:
node.set('package', devpac)
url = makeurl(apiurl, ['source', prj, pac, '_meta'])
mf = metafile(url, ET.tostring(root, encoding=ET_ENCODING))
mf.sync()
package_obj.devel = {"project": devprj, "package": devpac}

Check warning on line 3900 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3900

Added line #L3900 was not covered by tests

if package_obj.has_changed():
return package_obj.to_api(apiurl)

Check warning on line 3903 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3902-L3903

Added lines #L3902 - L3903 were not covered by tests

# TODO: debug log that we have skipped the API call
return None

Check warning on line 3906 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3906

Added line #L3906 was not covered by tests


def show_package_disabled_repos(apiurl: str, prj: str, pac: str):
Expand Down

0 comments on commit 3a6af40

Please sign in to comment.