mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-04 10:36:17 +01:00
Fix 'branch' command to allow using '--new-package' option on packages that do not exist
This commit is contained in:
parent
d42383551c
commit
abec6e5eb5
@ -19,7 +19,15 @@ OSC="osc -A https://localhost"
|
|||||||
# create projects
|
# create projects
|
||||||
$OSC api -X PUT '/source/openSUSE.org/_meta' --file "$FIXTURES_DIR/prj/openSUSE.org.xml"
|
$OSC api -X PUT '/source/openSUSE.org/_meta' --file "$FIXTURES_DIR/prj/openSUSE.org.xml"
|
||||||
$OSC api -X PUT '/source/test:devel/_meta' --file "$FIXTURES_DIR/prj/test_devel.xml"
|
$OSC api -X PUT '/source/test:devel/_meta' --file "$FIXTURES_DIR/prj/test_devel.xml"
|
||||||
|
|
||||||
|
# test:factory:update inherits from test:factory; test:factory has test:devel devel project
|
||||||
$OSC api -X PUT '/source/test:factory/_meta' --file "$FIXTURES_DIR/prj/test_factory.xml"
|
$OSC api -X PUT '/source/test:factory/_meta' --file "$FIXTURES_DIR/prj/test_factory.xml"
|
||||||
|
$OSC api -X PUT '/source/test:factory:update/_meta' --file "$FIXTURES_DIR/prj/test_factory_update.xml"
|
||||||
|
|
||||||
|
# test:leap:15.6:update inherits from test:leap:15.6; test:leap:15.6 has no devel project
|
||||||
|
$OSC api -X PUT '/source/test:leap:15.6/_meta' --file "$FIXTURES_DIR/prj/test_leap_15.6.xml"
|
||||||
|
$OSC api -X PUT '/source/test:leap:15.6:update/_meta' --file "$FIXTURES_DIR/prj/test_leap_15.6_update.xml"
|
||||||
|
|
||||||
$OSC api -X PUT '/source/test:release/_meta' --file "$FIXTURES_DIR/prj/test_release.xml"
|
$OSC api -X PUT '/source/test:release/_meta' --file "$FIXTURES_DIR/prj/test_release.xml"
|
||||||
$OSC api -X PUT '/source/home:Admin/_meta' --file "$FIXTURES_DIR/prj/home_Admin.xml"
|
$OSC api -X PUT '/source/home:Admin/_meta' --file "$FIXTURES_DIR/prj/home_Admin.xml"
|
||||||
|
|
||||||
@ -92,6 +100,24 @@ $OSC commit -m 'Initial commit'
|
|||||||
rm -rf "$TMP_DIR"
|
rm -rf "$TMP_DIR"
|
||||||
|
|
||||||
|
|
||||||
|
# create package 'test:leap:15.6/test-pkgA'
|
||||||
|
TMP_DIR=$(mktemp -d)
|
||||||
|
cd "$TMP_DIR"
|
||||||
|
|
||||||
|
$OSC checkout test:leap:15.6
|
||||||
|
cd "$_"
|
||||||
|
|
||||||
|
$OSC mkpac test-pkgA
|
||||||
|
cd "$_"
|
||||||
|
|
||||||
|
cp "$FIXTURES_DIR/pac/test-pkgA-1.spec" test-pkgA.spec
|
||||||
|
cp "$FIXTURES_DIR/pac/test-pkgA-1.changes" test-pkgA.changes
|
||||||
|
$OSC add test-pkgA.spec test-pkgA.changes
|
||||||
|
$OSC commit -m 'Initial commit'
|
||||||
|
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
|
||||||
|
|
||||||
# create package 'test:devel/test-pkgA'
|
# create package 'test:devel/test-pkgA'
|
||||||
TMP_DIR=$(mktemp -d)
|
TMP_DIR=$(mktemp -d)
|
||||||
cd "$TMP_DIR"
|
cd "$TMP_DIR"
|
||||||
|
65
behave/features/branch.feature
Normal file
65
behave/features/branch.feature
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
Feature: `osc branch` command
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch` on an inherited package that has no devel project set
|
||||||
|
When I execute osc with args "branch test:leap:15.6:update/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:leap:15.6/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:leap:15.6\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch --nodevelproject` on an inherited package that has no devel project set
|
||||||
|
When I execute osc with args "branch test:leap:15.6:update/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:leap:15.6/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:leap:15.6\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch --new-package` on an inherited package that has no devel project set
|
||||||
|
When I execute osc with args "branch --new-package test:leap:15.6:update/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:leap:15.6:update/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:leap:15.6:update\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch` on a package that has a devel project set
|
||||||
|
When I execute osc with args "branch test:factory/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:devel/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:devel\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch --nodevelproject` on a package that has a devel project set
|
||||||
|
When I execute osc with args "branch --nodevelproject test:factory/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:factory/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:factory\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch` on an inherited package that has a devel project set
|
||||||
|
When I execute osc with args "branch test:factory:update/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:devel/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:devel\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch --nodevelproject` on an inherited package that has a devel project set
|
||||||
|
When I execute osc with args "branch --nodevelproject test:factory:update/test-pkgA"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:factory/test-pkgA/_link"
|
||||||
|
And stdout contains "<link project=\"test:factory\""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
|
Scenario: Run `osc branch --new-package` on a package that doesn't exist
|
||||||
|
When I execute osc with args "branch --new-package test:factory/test-pkgNEW"
|
||||||
|
Then the exit code is 0
|
||||||
|
And I execute osc with args "api /source/home:Admin:branches:test:factory/test-pkgNEW/_link"
|
||||||
|
And stdout contains "<link project=\"test:factory\""
|
@ -9,6 +9,9 @@ Scenario: Run `osc list` with no arguments to display all projects
|
|||||||
openSUSE.org
|
openSUSE.org
|
||||||
test:devel
|
test:devel
|
||||||
test:factory
|
test:factory
|
||||||
|
test:factory:update
|
||||||
|
test:leap:15.6
|
||||||
|
test:leap:15.6:update
|
||||||
test:release
|
test:release
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ Scenario: Run `osc repo add` on a project
|
|||||||
|
|
||||||
@destructive
|
@destructive
|
||||||
Scenario: Run `osc repo remove` on a project
|
Scenario: Run `osc repo remove` on a project
|
||||||
When I execute osc with args "repo remove --yes test:factory --repo=standard --repo=does-not-exist"
|
When I execute osc with args "repo remove --yes test:factory:update --repo=standard --repo=does-not-exist"
|
||||||
And I execute osc with args "repo list test:factory"
|
And I execute osc with args "repo list test:factory:update"
|
||||||
Then stdout is
|
Then stdout is
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@ -9,6 +9,7 @@ Scenario: Run `osc token` with no arguments
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@destructive
|
||||||
Scenario: Run `osc token --operation rebuild`
|
Scenario: Run `osc token --operation rebuild`
|
||||||
When I execute osc with args "token --create --operation rebuild test:factory test-pkgA"
|
When I execute osc with args "token --create --operation rebuild test:factory test-pkgA"
|
||||||
Then stdout matches
|
Then stdout matches
|
||||||
|
@ -15,6 +15,7 @@ Scenario: Run `osc undelete <project>/<package>`
|
|||||||
|
|
||||||
@destructive
|
@destructive
|
||||||
Scenario: Run `osc undelete <project>`
|
Scenario: Run `osc undelete <project>`
|
||||||
Given I execute osc with args "rdelete test:factory --recursive -m 'why:delete'"
|
Given I execute osc with args "rdelete test:factory:update --recursive -m 'why:delete'"
|
||||||
When I execute osc with args "undelete test:factory -m 'why:undelete'"
|
And the exit code is 0
|
||||||
|
When I execute osc with args "undelete test:factory:update -m 'why:undelete'"
|
||||||
Then the exit code is 0
|
Then the exit code is 0
|
||||||
|
25
behave/fixtures/prj/test_factory_update.xml
Normal file
25
behave/fixtures/prj/test_factory_update.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<project name="test:factory:update">
|
||||||
|
|
||||||
|
<title/>
|
||||||
|
<description/>
|
||||||
|
|
||||||
|
<link project="test:factory"/>
|
||||||
|
|
||||||
|
<person userid="Admin" role="maintainer"/>
|
||||||
|
|
||||||
|
<lock>
|
||||||
|
<disable/>
|
||||||
|
</lock>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<disable/>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repository name="standard">
|
||||||
|
<path project="test:factory" repository="standard"/>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<arch>i586</arch>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
24
behave/fixtures/prj/test_leap_15.6.xml
Normal file
24
behave/fixtures/prj/test_leap_15.6.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<project name="test:leap:15.6">
|
||||||
|
|
||||||
|
<title/>
|
||||||
|
<description/>
|
||||||
|
|
||||||
|
<person userid="Admin" role="maintainer"/>
|
||||||
|
|
||||||
|
<lock>
|
||||||
|
<disable/>
|
||||||
|
</lock>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<disable/>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repository name="standard">
|
||||||
|
<!-- it's only for test purposes, let's use the same repo as test:factory -->
|
||||||
|
<path project="openSUSE.org:openSUSE:Tumbleweed" repository="standard"/>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<arch>i586</arch>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
25
behave/fixtures/prj/test_leap_15.6_update.xml
Normal file
25
behave/fixtures/prj/test_leap_15.6_update.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<project name="test:leap:15.6:update">
|
||||||
|
|
||||||
|
<title/>
|
||||||
|
<description/>
|
||||||
|
|
||||||
|
<link project="test:leap:15.6"/>
|
||||||
|
|
||||||
|
<person userid="Admin" role="maintainer"/>
|
||||||
|
|
||||||
|
<lock>
|
||||||
|
<disable/>
|
||||||
|
</lock>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<disable/>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repository name="standard">
|
||||||
|
<path project="test:leap:15.6" repository="standard"/>
|
||||||
|
<arch>x86_64</arch>
|
||||||
|
<arch>i586</arch>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
14
osc/core.py
14
osc/core.py
@ -6107,12 +6107,18 @@ def branch_pkg(
|
|||||||
# BEGIN: Error out on branching scmsync packages; this should be properly handled in the API
|
# BEGIN: Error out on branching scmsync packages; this should be properly handled in the API
|
||||||
|
|
||||||
# read src_package meta
|
# read src_package meta
|
||||||
m = b"".join(show_package_meta(apiurl, src_project, src_package))
|
try:
|
||||||
root = ET.fromstring(m)
|
m = b"".join(show_package_meta(apiurl, src_project, src_package))
|
||||||
|
root = ET.fromstring(m)
|
||||||
|
except HTTPError as e:
|
||||||
|
if e.code == 404 and missingok:
|
||||||
|
root = None
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
devel_project = None
|
devel_project = None
|
||||||
devel_package = None
|
devel_package = None
|
||||||
if not nodevelproject:
|
if root is not None and not nodevelproject:
|
||||||
devel_node = root.find("devel")
|
devel_node = root.find("devel")
|
||||||
if devel_node is not None:
|
if devel_node is not None:
|
||||||
devel_project = devel_node.get("project")
|
devel_project = devel_node.get("project")
|
||||||
@ -6123,7 +6129,7 @@ def branch_pkg(
|
|||||||
root = ET.fromstring(m)
|
root = ET.fromstring(m)
|
||||||
|
|
||||||
# error out if we're branching a scmsync package (we'd end up with garbage anyway)
|
# error out if we're branching a scmsync package (we'd end up with garbage anyway)
|
||||||
if root.find("scmsync") is not None:
|
if root is not None and root.find("scmsync") is not None:
|
||||||
msg = "Cannot branch a package with <scmsync> set."
|
msg = "Cannot branch a package with <scmsync> set."
|
||||||
if devel_project:
|
if devel_project:
|
||||||
raise oscerr.PackageError(devel_project, devel_package, msg)
|
raise oscerr.PackageError(devel_project, devel_package, msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user