mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-11 16:36:14 +01:00
Add --unset parameter to setdevelproject
Allows to unset the devel project (much like setlinkrev -u).
This commit is contained in:
parent
5ef2d4035c
commit
569e89fede
@ -553,6 +553,8 @@ class Osc(cmdln.Cmdln):
|
|||||||
print(devprj)
|
print(devprj)
|
||||||
|
|
||||||
@cmdln.alias('sdp')
|
@cmdln.alias('sdp')
|
||||||
|
@cmdln.option('-u', '--unset', action='store_true',
|
||||||
|
help='remove devel project')
|
||||||
def do_setdevelproject(self, subcmd, opts, *args):
|
def do_setdevelproject(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Set the devel project / package of a package
|
"""${cmd_name}: Set the devel project / package of a package
|
||||||
|
|
||||||
@ -575,7 +577,10 @@ class Osc(cmdln.Cmdln):
|
|||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
devpkg = args[1]
|
devpkg = args[1]
|
||||||
else:
|
else:
|
||||||
raise oscerr.WrongArgs('need at least DEVPRJ (and possibly DEVPKG)')
|
if opts.unset:
|
||||||
|
project, package = store_read_project(os.curdir), store_read_package(os.curdir)
|
||||||
|
else:
|
||||||
|
raise oscerr.WrongArgs('need at least DEVPRJ (and possibly DEVPKG)')
|
||||||
|
|
||||||
set_devel_project(apiurl, project, package, devprj, devpkg)
|
set_devel_project(apiurl, project, package, devprj, devpkg)
|
||||||
|
|
||||||
|
16
osc/core.py
16
osc/core.py
@ -3155,18 +3155,24 @@ def show_devel_project(apiurl, prj, pac):
|
|||||||
return node.get('project'), node.get('package', None)
|
return node.get('project'), node.get('package', None)
|
||||||
|
|
||||||
|
|
||||||
def set_devel_project(apiurl, prj, pac, devprj, devpac=None):
|
def set_devel_project(apiurl, prj, pac, devprj=None, devpac=None):
|
||||||
meta = show_package_meta(apiurl, prj, pac)
|
meta = show_package_meta(apiurl, prj, pac)
|
||||||
root = ET.fromstring(''.join(meta))
|
root = ET.fromstring(''.join(meta))
|
||||||
node = root.find('devel')
|
node = root.find('devel')
|
||||||
if node is None:
|
if node is None:
|
||||||
|
if devprj is None:
|
||||||
|
return
|
||||||
node = ET.Element('devel')
|
node = ET.Element('devel')
|
||||||
root.append(node)
|
root.append(node)
|
||||||
else:
|
else:
|
||||||
node.clear()
|
if devprj is None:
|
||||||
node.set('project', devprj)
|
root.remove(node)
|
||||||
if devpac:
|
else:
|
||||||
node.set('package', devpac)
|
node.clear()
|
||||||
|
if devprj:
|
||||||
|
node.set('project', devprj)
|
||||||
|
if devpac:
|
||||||
|
node.set('package', devpac)
|
||||||
url = makeurl(apiurl, ['source', prj, pac, '_meta'])
|
url = makeurl(apiurl, ['source', prj, pac, '_meta'])
|
||||||
mf = metafile(url, ET.tostring(root, encoding=ET_ENCODING))
|
mf = metafile(url, ET.tostring(root, encoding=ET_ENCODING))
|
||||||
mf.sync()
|
mf.sync()
|
||||||
|
Loading…
Reference in New Issue
Block a user