mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-13 07:56:14 +01:00
Fix develproject arg handling
This commit is contained in:
parent
19dcb3dc78
commit
bce0c3ffe4
@ -164,12 +164,15 @@ def pop_project_package_from_args(
|
|||||||
)
|
)
|
||||||
|
|
||||||
path = Path.cwd()
|
path = Path.cwd()
|
||||||
|
project_store = None
|
||||||
|
package_store = None
|
||||||
|
|
||||||
if project == ".":
|
if project == ".":
|
||||||
# project name taken from the working copy
|
# project name taken from the working copy
|
||||||
store = osc_store.Store(path)
|
project_store = osc_store.Store(path)
|
||||||
try:
|
try:
|
||||||
store = osc_store.Store(path)
|
project_store = osc_store.Store(path)
|
||||||
project = store.project
|
project = project_store.project
|
||||||
except oscerr.NoWorkingCopy:
|
except oscerr.NoWorkingCopy:
|
||||||
if not project_is_optional:
|
if not project_is_optional:
|
||||||
raise
|
raise
|
||||||
@ -178,13 +181,17 @@ def pop_project_package_from_args(
|
|||||||
if package == ".":
|
if package == ".":
|
||||||
# package name taken from the working copy
|
# package name taken from the working copy
|
||||||
try:
|
try:
|
||||||
store = osc_store.Store(path)
|
package_store = osc_store.Store(path)
|
||||||
store.assert_is_package()
|
package_store.assert_is_package()
|
||||||
package = store.package
|
package = package_store.package
|
||||||
except oscerr.NoWorkingCopy:
|
except oscerr.NoWorkingCopy:
|
||||||
if not package_is_optional:
|
if package_is_optional:
|
||||||
|
package = None
|
||||||
|
elif not project_store and default_package == ".":
|
||||||
|
# project wasn't retrieved from store, let's ask for specifying a package
|
||||||
|
raise oscerr.OscValueError("Please specify a package") from None
|
||||||
|
else:
|
||||||
raise
|
raise
|
||||||
package = None
|
|
||||||
|
|
||||||
return project, package
|
return project, package
|
||||||
|
|
||||||
@ -1033,9 +1040,7 @@ class Osc(cmdln.Cmdln):
|
|||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
|
|
||||||
args = list(args)
|
args = list(args)
|
||||||
project, package = pop_project_package_from_args(
|
project, package = pop_project_package_from_args(args, default_project=".", default_package=".")
|
||||||
args, package_is_optional=False
|
|
||||||
)
|
|
||||||
|
|
||||||
devel_project, devel_package = show_devel_project(apiurl, project, package)
|
devel_project, devel_package = show_devel_project(apiurl, project, package)
|
||||||
|
|
||||||
|
@ -192,6 +192,28 @@ class TestPopProjectPackageFromArgs(unittest.TestCase):
|
|||||||
self.assertEqual(package, "store_package")
|
self.assertEqual(package, "store_package")
|
||||||
self.assertEqual(args, [])
|
self.assertEqual(args, [])
|
||||||
|
|
||||||
|
def test_project_requires_to_specify_package(self):
|
||||||
|
args = ["project"]
|
||||||
|
self.assertRaises(
|
||||||
|
OscValueError,
|
||||||
|
pop_project_package_from_args,
|
||||||
|
args,
|
||||||
|
default_project=".",
|
||||||
|
default_package=".",
|
||||||
|
)
|
||||||
|
|
||||||
|
# The project from store is ignored because we've specified one.
|
||||||
|
# Specifying a package is expected.
|
||||||
|
self._write_store("store_project")
|
||||||
|
args = ["project"]
|
||||||
|
self.assertRaises(
|
||||||
|
OscValueError,
|
||||||
|
pop_project_package_from_args,
|
||||||
|
args,
|
||||||
|
default_project=".",
|
||||||
|
default_package=".",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestPopRepositoryArchFromArgs(unittest.TestCase):
|
class TestPopRepositoryArchFromArgs(unittest.TestCase):
|
||||||
def test_individial_args(self):
|
def test_individial_args(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user