mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-14 00:06:15 +01:00
Migrate 'setlinkrev' command to pop_project_package_from_args()
This commit is contained in:
parent
62ba626eb5
commit
37a34e58d4
39
behave/features/setlinkrev-project-package.feature
Normal file
39
behave/features/setlinkrev-project-package.feature
Normal file
@ -0,0 +1,39 @@
|
||||
Feature: `osc setlinkrev` 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 setlinkrev <project> <package>`
|
||||
When I execute osc with args "setlinkrev home:Admin test-pkgA"
|
||||
Then stdout is
|
||||
"""
|
||||
Set link revision of package home:Admin/test-pkgA to 3
|
||||
"""
|
||||
|
||||
|
||||
Scenario: Run `osc setlinkrev <project>/<package>`
|
||||
When I execute osc with args "setlinkrev home:Admin/test-pkgA"
|
||||
Then stdout is
|
||||
"""
|
||||
Set link revision of package home:Admin/test-pkgA to 3
|
||||
"""
|
||||
|
||||
|
||||
Scenario: Run `osc setlinkrev <project> <package> --revision`
|
||||
When I execute osc with args "setlinkrev home:Admin test-pkgA --revision=2"
|
||||
Then stdout is
|
||||
"""
|
||||
Set link revision of package home:Admin/test-pkgA to 2
|
||||
"""
|
||||
|
||||
|
||||
Scenario: Run `osc setlinkrev <project> <package> --unset`
|
||||
When I execute osc with args "setlinkrev home:Admin test-pkgA --unset"
|
||||
Then stdout is
|
||||
"""
|
||||
Removed link revision from package home:Admin/test-pkgA
|
||||
"""
|
33
behave/features/setlinkrev-project.feature
Normal file
33
behave/features/setlinkrev-project.feature
Normal file
@ -0,0 +1,33 @@
|
||||
Feature: `osc setlinkrev` 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 setlinkrev <project>`
|
||||
When I execute osc with args "setlinkrev home:Admin"
|
||||
Then stdout is
|
||||
"""
|
||||
Set link revision of package home:Admin/test-pkgA to 3
|
||||
"""
|
||||
|
||||
|
||||
Scenario: Run `osc setlinkrev <project> --revision`
|
||||
When I execute osc with args "setlinkrev home:Admin --revision=2"
|
||||
Then the exit code is 2
|
||||
|
||||
|
||||
Scenario: Run `osc setlinkrev <project> --unset`
|
||||
Given I execute osc with args "setlinkrev home:Admin test-pkgA --revision=2"
|
||||
And stdout is
|
||||
"""
|
||||
Set link revision of package home:Admin/test-pkgA to 2
|
||||
"""
|
||||
When I execute osc with args "setlinkrev home:Admin --unset"
|
||||
Then stdout is
|
||||
"""
|
||||
Removed link revision from package home:Admin/test-pkgA
|
||||
"""
|
@ -2773,27 +2773,28 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
osc setlinkrev PROJECT [PACKAGE]
|
||||
"""
|
||||
|
||||
args = slash_split(args)
|
||||
apiurl = self.get_api_url()
|
||||
package = None
|
||||
|
||||
rev = parseRevisionOption(opts.revision)[0] or ''
|
||||
if opts.unset:
|
||||
rev = None
|
||||
|
||||
args = list(args)
|
||||
if not args:
|
||||
p = Package(Path.cwd())
|
||||
project = p.prjname
|
||||
package = p.name
|
||||
apiurl = p.apiurl
|
||||
assert apiurl == p.apiurl
|
||||
if not p.islink():
|
||||
sys.exit('Local directory is no checked out source link package, aborting')
|
||||
elif len(args) == 2:
|
||||
project = self._process_project_name(args[0])
|
||||
package = args[1]
|
||||
elif len(args) == 1:
|
||||
project = self._process_project_name(args[0])
|
||||
else:
|
||||
self.argparse_error("Incorrect number of arguments.")
|
||||
project, package = pop_project_package_from_args(
|
||||
args, default_project=".", default_package=".", package_is_optional=True
|
||||
)
|
||||
|
||||
if opts.revision and not package:
|
||||
# It is highly unlikely that all links for all packages in a project should be set to the same revision.
|
||||
self.argparse_error("The --revision option requires to specify a package")
|
||||
|
||||
if package:
|
||||
packages = [package]
|
||||
@ -2801,12 +2802,18 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
packages = meta_get_packagelist(apiurl, project)
|
||||
|
||||
for p in packages:
|
||||
rev = set_link_rev(apiurl, project, p, revision=rev,
|
||||
expand=not opts.use_plain_revision)
|
||||
try:
|
||||
rev = set_link_rev(apiurl, project, p, revision=rev, expand=not opts.use_plain_revision)
|
||||
except HTTPError as e:
|
||||
if e.code != 404:
|
||||
raise
|
||||
print(f"WARNING: Package {project}/{p} has no link", file=sys.stderr)
|
||||
continue
|
||||
|
||||
if rev is None:
|
||||
print('removed revision from link')
|
||||
print(f"Removed link revision from package {project}/{p}")
|
||||
else:
|
||||
print('set revision to %s for package %s' % (rev, p))
|
||||
print(f"Set link revision of package {project}/{p} to {rev}")
|
||||
|
||||
def do_linktobranch(self, subcmd, opts, *args):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user