mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-26 04:02:11 +01:00
Move showlinked code from commandline to _private
This commit is contained in:
parent
2f70408dea
commit
4634690176
17
behave/features/showlinked-pkgcheckout.feature
Normal file
17
behave/features/showlinked-pkgcheckout.feature
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Feature: `osc showlinked` 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"
|
||||||
|
And I execute osc with args "linkpac test:factory/test-pkgA home:Admin --force"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc showlinked`
|
||||||
|
When I execute osc with args "showlinked"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
home:Admin/test-pkgA
|
||||||
|
"""
|
17
behave/features/showlinked-prjcheckout.feature
Normal file
17
behave/features/showlinked-prjcheckout.feature
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Feature: `osc showlinked` 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 showlinked`
|
||||||
|
When I execute osc with args "showlinked"
|
||||||
|
Then the exit code is 1
|
||||||
|
And stderr is
|
||||||
|
"""
|
||||||
|
Directory '{context.osc.temp}/test:factory' is not a working copy of a package
|
||||||
|
"""
|
23
behave/features/showlinked-project-package.feature
Normal file
23
behave/features/showlinked-project-package.feature
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Feature: `osc showlinked` command
|
||||||
|
|
||||||
|
|
||||||
|
# common steps for all scenarios
|
||||||
|
Background:
|
||||||
|
Given I set working directory to "{context.osc.temp}"
|
||||||
|
And I execute osc with args "linkpac test:factory/test-pkgA home:Admin --force"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc showlinked <project> <package>`
|
||||||
|
When I execute osc with args "showlinked test:factory test-pkgA"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
home:Admin/test-pkgA
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: Run `osc showlinked <project>/<package>`
|
||||||
|
When I execute osc with args "showlinked test:factory/test-pkgA"
|
||||||
|
Then stdout is
|
||||||
|
"""
|
||||||
|
home:Admin/test-pkgA
|
||||||
|
"""
|
@ -6,6 +6,7 @@
|
|||||||
from .api_source import add_channels
|
from .api_source import add_channels
|
||||||
from .api_source import add_containers
|
from .api_source import add_containers
|
||||||
from .api_source import enable_channels
|
from .api_source import enable_channels
|
||||||
|
from .api_source import get_linked_packages
|
||||||
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
|
||||||
from .package import ApiPackage
|
from .package import ApiPackage
|
||||||
|
@ -66,3 +66,19 @@ def enable_channels(apiurl, project, package=None, print_to="debug"):
|
|||||||
url_query = {"cmd": "modifychannels", "mode": "enable_all"}
|
url_query = {"cmd": "modifychannels", "mode": "enable_all"}
|
||||||
|
|
||||||
return api.post(apiurl, url_path, url_query)
|
return api.post(apiurl, url_path, url_query)
|
||||||
|
|
||||||
|
|
||||||
|
def get_linked_packages(apiurl, project, package):
|
||||||
|
url_path = ["source", project, package]
|
||||||
|
url_query = {"cmd": "showlinked"}
|
||||||
|
root = api.post(apiurl, url_path, url_query)
|
||||||
|
|
||||||
|
result = []
|
||||||
|
nodes = api.find_nodes(root, "collection", "package")
|
||||||
|
for node in nodes:
|
||||||
|
item = {
|
||||||
|
"project": node.get("project"),
|
||||||
|
"name": node.get("name"),
|
||||||
|
}
|
||||||
|
result.append(item)
|
||||||
|
return result
|
||||||
|
@ -826,24 +826,16 @@ class Osc(cmdln.Cmdln):
|
|||||||
osc showlinked [PROJECT PACKAGE]
|
osc showlinked [PROJECT PACKAGE]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args = slash_split(args)
|
|
||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
localdir = Path.cwd()
|
|
||||||
project = package = None
|
|
||||||
if len(args) == 2:
|
|
||||||
project = self._process_project_name(args[0])
|
|
||||||
package = args[1]
|
|
||||||
elif is_package_dir(localdir):
|
|
||||||
project = store_read_project(localdir)
|
|
||||||
package = store_read_package(localdir)
|
|
||||||
else:
|
|
||||||
raise oscerr.WrongArgs('Either specify project and package or call it from a package working copy')
|
|
||||||
|
|
||||||
url = makeurl(apiurl, ['source', project, package], query={'cmd': 'showlinked'})
|
args = list(args)
|
||||||
f = http_POST(url)
|
project, package = pop_project_package_from_args(
|
||||||
root = ET.parse(f).getroot()
|
args, default_project=".", default_package=".", package_is_optional=False
|
||||||
for node in root.findall('package'):
|
)
|
||||||
print(node.get('project') + " " + node.get('name'))
|
|
||||||
|
linked_packages = _private.get_linked_packages(apiurl, project, package)
|
||||||
|
for pkg in linked_packages:
|
||||||
|
print(f"{pkg['project']}/{pkg['name']}")
|
||||||
|
|
||||||
@cmdln.option('-c', '--create', action='store_true',
|
@cmdln.option('-c', '--create', action='store_true',
|
||||||
help='Create a new token')
|
help='Create a new token')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user