mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
Allow commits to linked pakages.
If the package is linked to a different project, osc will ask permision to branch the package in the current project before commiting. Show a message in osc meta pkg -e in the same case.
This commit is contained in:
parent
87e24c3aa6
commit
a20c6f5d99
38
osc/core.py
38
osc/core.py
@ -1310,6 +1310,23 @@ class Package:
|
|||||||
# information (like which service/command failed)
|
# information (like which service/command failed)
|
||||||
raise oscerr.ServiceRuntimeError('A service failed with error: %d' % r)
|
raise oscerr.ServiceRuntimeError('A service failed with error: %d' % r)
|
||||||
|
|
||||||
|
# check if it is a link, if so, branch the package
|
||||||
|
orgprj = self.get_local_origin_project()
|
||||||
|
if self.prjname != orgprj:
|
||||||
|
print('Currect project:', self.prjname)
|
||||||
|
print('Linked project:', orgprj)
|
||||||
|
repl = raw_input('The package is linked from a different project.' \
|
||||||
|
' Create a local branch before commit? (y|N) ')
|
||||||
|
if repl in('y', 'Y'):
|
||||||
|
exists, targetprj, targetpkg, srcprj, srcpkg = branch_pkg(self.apiurl, orgprj, self.name,
|
||||||
|
target_project=self.prjname)
|
||||||
|
# update _meta and _files to sychronize the local package
|
||||||
|
# to the new branched one in OBS
|
||||||
|
self.update_local_pacmeta()
|
||||||
|
self.update_local_filesmeta()
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
|
|
||||||
if not self.todo:
|
if not self.todo:
|
||||||
self.todo = [i for i in self.to_be_added if not i in self.filenamelist] + self.filenamelist
|
self.todo = [i for i in self.to_be_added if not i in self.filenamelist] + self.filenamelist
|
||||||
|
|
||||||
@ -1538,6 +1555,16 @@ class Package:
|
|||||||
e.set('skipped', 'true')
|
e.set('skipped', 'true')
|
||||||
return ET.tostring(root, encoding=ET_ENCODING)
|
return ET.tostring(root, encoding=ET_ENCODING)
|
||||||
|
|
||||||
|
def get_local_meta(self):
|
||||||
|
"""Get the local _meta file for the package."""
|
||||||
|
meta = store_read_file(self.absdir, '_meta')
|
||||||
|
return meta
|
||||||
|
|
||||||
|
def get_local_origin_project(self):
|
||||||
|
"""Get the originproject from the _meta file."""
|
||||||
|
root = ET.fromstring(self.get_local_meta())
|
||||||
|
return root.get('project')
|
||||||
|
|
||||||
def update_datastructs(self):
|
def update_datastructs(self):
|
||||||
"""
|
"""
|
||||||
Update the internal data structures if the local _files
|
Update the internal data structures if the local _files
|
||||||
@ -3376,6 +3403,17 @@ def edit_meta(metatype,
|
|||||||
if edit:
|
if edit:
|
||||||
change_is_required = True
|
change_is_required = True
|
||||||
|
|
||||||
|
if metatype == 'pkg':
|
||||||
|
# check if the package is a link to a different project
|
||||||
|
project, package = path_args
|
||||||
|
orgprj = ET.fromstring(''.join(data)).get('project')
|
||||||
|
if project != orgprj:
|
||||||
|
print('The package is linked from a different project.')
|
||||||
|
print('If you want to edit the meta of the package create first a branch.')
|
||||||
|
print(' osc branch %s %s %s' % (orgprj, package, unquote(project)))
|
||||||
|
print(' osc meta pkg %s %s -e' % (unquote(project), package))
|
||||||
|
return
|
||||||
|
|
||||||
url = make_meta_url(metatype, path_args, apiurl, force, remove_linking_repositories)
|
url = make_meta_url(metatype, path_args, apiurl, force, remove_linking_repositories)
|
||||||
f = metafile(url, data, change_is_required, metatypes[metatype]['file_ext'])
|
f = metafile(url, data, change_is_required, metatypes[metatype]['file_ext'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user