mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-03 18:16:17 +01:00
Move addcontainers code from commandline to _private
This commit is contained in:
parent
6dcc45f272
commit
2f70408dea
24
behave/features/addcontainers-pkgcheckout.feature
Normal file
24
behave/features/addcontainers-pkgcheckout.feature
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Feature: `osc addcontainers` command
|
||||||
|
|
||||||
|
|
||||||
|
# common steps for all scenarios
|
||||||
|
Background:
|
||||||
|
Given I set working directory to "{context.osc.temp}"
|
||||||
|
And I execute osc with args "checkout test:factory test-pkgA"
|
||||||
|
And I set working directory to "{context.osc.temp}/test:factory/test-pkgA"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers`
|
||||||
|
When I execute osc with args "addcontainers"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
Adding containers to package 'test:factory/test-pkgA'
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers --extend-package-names`
|
||||||
|
When I execute osc with args "addcontainers --extend-package-names"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
Adding containers to package 'test:factory/test-pkgA' options: extend-package-names
|
||||||
|
"""
|
17
behave/features/addcontainers-prjcheckout.feature
Normal file
17
behave/features/addcontainers-prjcheckout.feature
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Feature: `osc addcontainers` command
|
||||||
|
|
||||||
|
|
||||||
|
# common steps for all scenarios
|
||||||
|
Background:
|
||||||
|
Given I set working directory to "{context.osc.temp}"
|
||||||
|
And I execute osc with args "checkout test:factory"
|
||||||
|
And I set working directory to "{context.osc.temp}/test:factory"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers`
|
||||||
|
When I execute osc with args "addcontainers"
|
||||||
|
Then the exit code is 1
|
||||||
|
And stderr is
|
||||||
|
"""
|
||||||
|
Directory '{context.osc.temp}/test:factory' is not a working copy of a package
|
||||||
|
"""
|
30
behave/features/addcontainers-project-package.feature
Normal file
30
behave/features/addcontainers-project-package.feature
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Feature: `osc addcontainers` command
|
||||||
|
|
||||||
|
|
||||||
|
# common steps for all scenarios
|
||||||
|
Background:
|
||||||
|
Given I set working directory to "{context.osc.temp}"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers <project> <package>`
|
||||||
|
When I execute osc with args "addcontainers test:factory test-pkgA"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
Adding containers to package 'test:factory/test-pkgA'
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers <project>/<package>`
|
||||||
|
When I execute osc with args "addcontainers test:factory/test-pkgA"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
Adding containers to package 'test:factory/test-pkgA'
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc addcontainers <project> <package> --extend-package-names`
|
||||||
|
When I execute osc with args "addcontainers test:factory test-pkgA --extend-package-names"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
Adding containers to package 'test:factory/test-pkgA' options: extend-package-names
|
||||||
|
"""
|
@ -4,6 +4,7 @@
|
|||||||
# The cherry-picked imports will be the supported API.
|
# The cherry-picked imports will be the supported API.
|
||||||
|
|
||||||
from .api_source import add_channels
|
from .api_source import add_channels
|
||||||
|
from .api_source import add_containers
|
||||||
from .api_source import enable_channels
|
from .api_source import enable_channels
|
||||||
from .common import print_msg
|
from .common import print_msg
|
||||||
from .common import format_msg_project_package_options
|
from .common import format_msg_project_package_options
|
||||||
|
@ -30,6 +30,24 @@ def add_channels(apiurl, project, package=None, enable_all=False, skip_disabled=
|
|||||||
return api.post(apiurl, url_path, url_query)
|
return api.post(apiurl, url_path, url_query)
|
||||||
|
|
||||||
|
|
||||||
|
def add_containers(apiurl, project, package, extend_package_names=False, print_to="debug"):
|
||||||
|
msg = format_msg_project_package_options(
|
||||||
|
"Adding containers to",
|
||||||
|
project,
|
||||||
|
package,
|
||||||
|
extend_package_names=extend_package_names,
|
||||||
|
)
|
||||||
|
print_msg(msg, print_to=print_to)
|
||||||
|
|
||||||
|
url_path = ["source", project, package]
|
||||||
|
|
||||||
|
url_query = {"cmd": "addcontainers"}
|
||||||
|
if extend_package_names:
|
||||||
|
url_query["extend_package_names"] = "1"
|
||||||
|
|
||||||
|
return api.post(apiurl, url_path, url_query)
|
||||||
|
|
||||||
|
|
||||||
def enable_channels(apiurl, project, package=None, print_to="debug"):
|
def enable_channels(apiurl, project, package=None, print_to="debug"):
|
||||||
msg = format_msg_project_package_options(
|
msg = format_msg_project_package_options(
|
||||||
"Enabling channels in",
|
"Enabling channels in",
|
||||||
|
@ -595,28 +595,16 @@ class Osc(cmdln.Cmdln):
|
|||||||
osc addcontainers [PROJECT PACKAGE]
|
osc addcontainers [PROJECT PACKAGE]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args = slash_split(args)
|
|
||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
localdir = Path.cwd()
|
|
||||||
project = package = None
|
|
||||||
if not args:
|
|
||||||
if is_package_dir(localdir):
|
|
||||||
project = store_read_project(localdir)
|
|
||||||
package = store_read_package(localdir)
|
|
||||||
elif len(args) == 2:
|
|
||||||
project = self._process_project_name(args[0])
|
|
||||||
package = args[1]
|
|
||||||
|
|
||||||
if project is None or package is None:
|
args = list(args)
|
||||||
raise oscerr.WrongArgs('Either specify project and package or call it from a package working copy')
|
project, package = pop_project_package_from_args(
|
||||||
|
args, default_project=".", default_package=".", package_is_optional=False
|
||||||
|
)
|
||||||
|
|
||||||
query = {'cmd': 'addcontainers'}
|
_private.add_containers(
|
||||||
if opts.extend_package_names:
|
apiurl, project, package, extend_package_names=opts.extend_package_names, print_to="stdout"
|
||||||
query['extend_package_names'] = '1'
|
)
|
||||||
|
|
||||||
print("Add containers...")
|
|
||||||
url = makeurl(apiurl, ['source', project, package], query=query)
|
|
||||||
f = http_POST(url)
|
|
||||||
|
|
||||||
@cmdln.option('-s', '--skip-disabled', action='store_true',
|
@cmdln.option('-s', '--skip-disabled', action='store_true',
|
||||||
help='Skip disabled channels. Otherwise the source gets added, but not the repositories.')
|
help='Skip disabled channels. Otherwise the source gets added, but not the repositories.')
|
||||||
|
Loading…
Reference in New Issue
Block a user