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 75dcb72 commit a22bf36
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3886,26 +3886,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 3889 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3889

Added line #L3889 was not covered by tests

if devprj is None:
package_obj.devel = None

Check warning on line 3892 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3891-L3892

Added lines #L3891 - L3892 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 3894 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3894

Added line #L3894 was not covered by tests

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

Check warning on line 3897 in osc/core.py

View check run for this annotation

Codecov / codecov/patch

osc/core.py#L3896-L3897

Added lines #L3896 - L3897 were not covered by tests

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

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


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

0 comments on commit a22bf36

Please sign in to comment.