mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-23 10:42:14 +01:00
Merge pull request #1693 from dmach/fix-linkpac-project-link
Fix 'linkpac' command for projects with a project link
This commit is contained in:
commit
f2b83ec7f6
@ -35,9 +35,18 @@ Scenario: Run `osc linkpac --disable-publish`
|
|||||||
|
|
||||||
|
|
||||||
@destructive
|
@destructive
|
||||||
Scenario: Run `osc linkpac on a locked package`
|
Scenario: Run `osc linkpac` on a locked package
|
||||||
Given I execute osc with args "lock test:factory/test-pkgA"
|
Given I execute osc with args "lock test:factory/test-pkgA"
|
||||||
When I execute osc with args "linkpac test:factory/test-pkgA home:Admin/test-pkgA"
|
When I execute osc with args "linkpac test:factory/test-pkgA home:Admin/test-pkgA"
|
||||||
Then the exit code is 0
|
Then the exit code is 0
|
||||||
And I execute osc with args "api /source/home:Admin/test-pkgA/_meta"
|
And I execute osc with args "api /source/home:Admin/test-pkgA/_meta"
|
||||||
And stdout doesn't contain "<lock>\s*<enable/>\s*</lock>"
|
And stdout doesn't contain "<lock>\s*<enable/>\s*</lock>"
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc linkpac` with target project that has a project link
|
||||||
|
Given I execute osc with args "api -X PUT /source/home:Admin/_meta --data='<project name="home:Admin"><title/><description/><link project="test:factory"/></project>'"
|
||||||
|
When I execute osc with args "linkpac test:factory/test-pkgA home:Admin"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:factory\" package=\"test-pkgA\">"
|
||||||
|
13
osc/core.py
13
osc/core.py
@ -3287,12 +3287,21 @@ def link_pac(
|
|||||||
|
|
||||||
apiurl = conf.config["apiurl"]
|
apiurl = conf.config["apiurl"]
|
||||||
|
|
||||||
|
create_dst_package = False
|
||||||
src_package_obj = obs_api.Package.from_api(apiurl, src_project, src_package)
|
src_package_obj = obs_api.Package.from_api(apiurl, src_project, src_package)
|
||||||
try:
|
try:
|
||||||
dst_package_obj = obs_api.Package.from_api(apiurl, dst_project, dst_package)
|
dst_package_obj = obs_api.Package.from_api(apiurl, dst_project, dst_package)
|
||||||
|
if dst_package_obj.project != dst_project:
|
||||||
|
# If the target package doesn't exist and the target project contains a project link,
|
||||||
|
# the package meta from the linked project is returned instead!
|
||||||
|
# We need to detect it and create the target package based on source package meta.
|
||||||
|
create_dst_package = True
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.code != 404:
|
if e.code != 404:
|
||||||
raise
|
raise
|
||||||
|
create_dst_package = True
|
||||||
|
|
||||||
|
if create_dst_package:
|
||||||
if missing_target:
|
if missing_target:
|
||||||
# we start with empty values because we want has_changed() to return True
|
# we start with empty values because we want has_changed() to return True
|
||||||
dst_package_obj = obs_api.Package(project="", name="")
|
dst_package_obj = obs_api.Package(project="", name="")
|
||||||
@ -3317,11 +3326,11 @@ def link_pac(
|
|||||||
if disable_publish:
|
if disable_publish:
|
||||||
dst_package_obj.publish_list = [{"flag": "disable"}]
|
dst_package_obj.publish_list = [{"flag": "disable"}]
|
||||||
|
|
||||||
|
dst_package_obj.scmsync = None
|
||||||
|
|
||||||
if dst_package_obj.has_changed():
|
if dst_package_obj.has_changed():
|
||||||
dst_package_obj.to_api(apiurl)
|
dst_package_obj.to_api(apiurl)
|
||||||
|
|
||||||
dst_package_obj.scmsync = None
|
|
||||||
|
|
||||||
# create the _link file
|
# create the _link file
|
||||||
# but first, make sure not to overwrite an existing one
|
# but first, make sure not to overwrite an existing one
|
||||||
if '_link' in meta_get_filelist(apiurl, dst_project, dst_package):
|
if '_link' in meta_get_filelist(apiurl, dst_project, dst_package):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user