Skip to content

Commit

Permalink
Support copy of scmsync packages
Browse files Browse the repository at this point in the history
There are two ways, either copy the scmsync definition or drop it
when creating a new package meta.

If we keep it, we must not ask OBS to copy sources, it is syncing it
anyway.

We could add another option to skip the scmsync tag copy, but we keep
it as default, because we don't want to give a different view of the
the sources to the user.  The client side copy is doing this.
  • Loading branch information
adrianschroeter committed Sep 11, 2024
1 parent 0302053 commit b991b50
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3206,7 +3206,7 @@ def checkout_package(

def replace_pkg_meta(
pkgmeta, new_name: str, new_prj: str, keep_maintainers=False, dst_userid=None, keep_develproject=False,
keep_lock: bool = False,
keep_lock: bool = False, keep_scmsync: bool = True,
):
"""
update pkgmeta with new new_name and new_prj and set calling user as the
Expand All @@ -3230,6 +3230,9 @@ def replace_pkg_meta(
if not keep_lock:
for node in root.findall("lock"):
root.remove(node)
if not keep_scmsync:
for node in root.findall("scmsync"):
root.remove(node)
return ET.tostring(root, encoding=ET_ENCODING)


Expand Down Expand Up @@ -3732,12 +3735,13 @@ def copy_pac(
if not any([expand, revision]):
raise oscerr.OscValueError("Cannot copy package. Source and target are the same.")

meta = None
if not (src_apiurl == dst_apiurl and src_project == dst_project
and src_package == dst_package):
src_meta = show_package_meta(src_apiurl, src_project, src_package)
dst_userid = conf.get_apiurl_usr(dst_apiurl)
src_meta = replace_pkg_meta(src_meta, dst_package, dst_project, keep_maintainers,
dst_userid, keep_develproject)
meta = replace_pkg_meta(src_meta, dst_package, dst_project, keep_maintainers,
dst_userid, keep_develproject, keep_scmsync=(not client_side_copy))

url = make_meta_url('pkg', (dst_project, dst_package), dst_apiurl)
found = None
Expand All @@ -3748,7 +3752,15 @@ def copy_pac(
if force_meta_update or not found:
print('Sending meta data...')
u = makeurl(dst_apiurl, ['source', dst_project, dst_package, '_meta'])
http_PUT(u, data=src_meta)
http_PUT(u, data=meta)

if meta is None:
meta = show_package_meta(dst_apiurl, dst_project, dst_package)

root = ET.fromstring(meta)
if root.find("scmsync") is not None:
print("Note: package source is managed via SCM")
return

print('Copying files...')
if not client_side_copy:
Expand Down

0 comments on commit b991b50

Please sign in to comment.