1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 22:56:15 +01:00

Move 'release' code from commandline to _private

This commit is contained in:
Daniel Mach 2022-11-10 10:29:14 +01:00
parent 56bb193b4e
commit 3027edc0eb
3 changed files with 59 additions and 41 deletions

View File

@ -7,6 +7,7 @@ from .api_source import add_channels
from .api_source import add_containers
from .api_source import enable_channels
from .api_source import get_linked_packages
from .api_source import release
from .common import print_msg
from .common import format_msg_project_package_options
from .package import ApiPackage

View File

@ -82,3 +82,45 @@ def get_linked_packages(apiurl, project, package):
}
result.append(item)
return result
def release(
apiurl,
project,
package,
repository,
target_project,
target_repository,
set_release_to=None,
delayed=False,
print_to="debug",
):
msg = format_msg_project_package_options(
"Releasing",
project,
package,
target_project,
target_package=None,
repository=repository,
dest_repository=target_repository,
delayed=delayed,
)
print_msg(msg, print_to=print_to)
url_path = ["source", project]
if package:
url_path += [package]
url_query = {"cmd": "release"}
if repository:
url_query["repository"] = repository
if target_project:
url_query["target_project"] = target_project
if target_repository:
url_query["target_repository"] = target_repository
if set_release_to:
url_query["setrelease"] = set_release_to
if not delayed:
url_query["nodelay"] = "1"
return api.post(apiurl, url_path, url_query)

View File

@ -3136,51 +3136,26 @@ Please submit there instead, or use --nodevelproject to force direct submission.
It requires defined release targets set to trigger="manual".
usage:
osc release [ SOURCEPROJECT [ SOURCEPACKAGE ] ]
osc release [PROJECT [PACKAGE]]
"""
args = slash_split(args)
apiurl = self.get_api_url()
source_project = source_package = None
args = list(args)
project, package = pop_project_package_from_args(
args, default_project=".", default_package=".", package_is_optional=True
)
if len(args) > 2:
raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0:
if is_package_dir(Path.cwd()):
source_project = store_read_project(Path.cwd())
source_package = store_read_package(Path.cwd())
elif is_project_dir(Path.cwd()):
source_project = store_read_project(Path.cwd())
else:
raise oscerr.WrongArgs('Too few arguments.')
if len(args) > 0:
source_project = self._process_project_name(args[0])
if len(args) > 1:
source_package = args[1]
query = {'cmd': 'release'}
if opts.target_project:
query["target_project"] = opts.target_project
if opts.target_repository:
query["target_repository"] = opts.target_repository
if opts.repo:
query["repository"] = opts.repo
if opts.set_release:
query["setrelease"] = opts.set_release
if opts.no_delay:
query["nodelay"] = "1"
baseurl = ['source', source_project]
if source_package:
baseurl.append(source_package)
url = makeurl(apiurl, baseurl, query=query)
f = http_POST(url)
while True:
buf = f.read(16384)
if not buf:
break
sys.stdout.write(decode_it(buf))
_private.release(
apiurl,
project=project,
package=package,
repository=opts.repo,
target_project=opts.target_project,
target_repository=opts.target_repository,
set_release_to=opts.set_release,
delayed=not opts.no_delay,
print_to="stdout",
)
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')