mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-05 19:00:56 +01:00
Migrate core.set_devel_project() to obs_api.Package
This commit is contained in:
parent
ab36108871
commit
b03f5d3b86
@ -15,8 +15,6 @@ Scenario: Run `osc setdevelproject <devel_project>`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -27,8 +25,6 @@ Scenario: Run `osc setdevelproject <devel_project> <devel_package>`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -39,8 +35,6 @@ Scenario: Run `osc setdevelproject <devel_project>/<devel_package>`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -52,6 +46,4 @@ Scenario: Run `osc setdevelproject --unset`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Unsetting devel project from package 'test:factory/test-pkgA'
|
Unsetting devel project from package 'test:factory/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
@ -13,8 +13,6 @@ Scenario: Run `osc setdevelproject <project> <package> <devel_project>`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgA' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -25,8 +23,6 @@ Scenario: Run `osc setdevelproject <project> <package> <devel_project> <devel_pa
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgB' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgB' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -37,8 +33,6 @@ Scenario: Run `osc setdevelproject <project>/<package> <devel_project>/<devel_p
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Setting devel project of package 'test:factory/test-pkgB' to package 'test:devel/test-pkgA'
|
Setting devel project of package 'test:factory/test-pkgB' to package 'test:devel/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +43,4 @@ Scenario: Run `osc setdevelproject <project> <package> --unset`
|
|||||||
And stdout is
|
And stdout is
|
||||||
"""
|
"""
|
||||||
Unsetting devel project from package 'test:factory/test-pkgA'
|
Unsetting devel project from package 'test:factory/test-pkgA'
|
||||||
Sending meta data...
|
|
||||||
Done.
|
|
||||||
"""
|
"""
|
||||||
|
30
osc/core.py
30
osc/core.py
@ -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"):
|
def set_devel_project(apiurl, prj, pac, devprj=None, devpac=None, print_to="debug"):
|
||||||
|
from . import obs_api
|
||||||
|
|
||||||
if devprj:
|
if devprj:
|
||||||
msg = "Setting devel project of"
|
msg = "Setting devel project of"
|
||||||
else:
|
else:
|
||||||
@ -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)
|
_private.print_msg(msg, print_to=print_to)
|
||||||
|
|
||||||
meta = show_package_meta(apiurl, prj, pac)
|
package_obj = obs_api.Package.from_api(apiurl, prj, pac)
|
||||||
root = ET.fromstring(b''.join(meta))
|
|
||||||
node = root.find('devel')
|
|
||||||
if node is None:
|
|
||||||
if devprj is None:
|
if devprj is None:
|
||||||
return
|
package_obj.devel = None
|
||||||
node = ET.Element('devel')
|
|
||||||
root.append(node)
|
|
||||||
else:
|
else:
|
||||||
if devprj is None:
|
package_obj.devel = {"project": devprj, "package": devpac}
|
||||||
root.remove(node)
|
|
||||||
else:
|
if package_obj.has_changed():
|
||||||
node.clear()
|
return package_obj.to_api(apiurl)
|
||||||
if devprj:
|
|
||||||
node.set('project', devprj)
|
# TODO: debug log that we have skipped the API call
|
||||||
if devpac:
|
return None
|
||||||
node.set('package', devpac)
|
|
||||||
url = makeurl(apiurl, ['source', prj, pac, '_meta'])
|
|
||||||
mf = metafile(url, ET.tostring(root, encoding=ET_ENCODING))
|
|
||||||
mf.sync()
|
|
||||||
|
|
||||||
|
|
||||||
def show_package_disabled_repos(apiurl: str, prj: str, pac: str):
|
def show_package_disabled_repos(apiurl: str, prj: str, pac: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user