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:
parent
56bb193b4e
commit
3027edc0eb
@ -7,6 +7,7 @@ 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 .api_source import get_linked_packages
|
||||||
|
from .api_source import release
|
||||||
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
|
||||||
|
@ -82,3 +82,45 @@ def get_linked_packages(apiurl, project, package):
|
|||||||
}
|
}
|
||||||
result.append(item)
|
result.append(item)
|
||||||
return result
|
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)
|
||||||
|
@ -3136,51 +3136,26 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
It requires defined release targets set to trigger="manual".
|
It requires defined release targets set to trigger="manual".
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
osc release [ SOURCEPROJECT [ SOURCEPACKAGE ] ]
|
osc release [PROJECT [PACKAGE]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args = slash_split(args)
|
|
||||||
apiurl = self.get_api_url()
|
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:
|
_private.release(
|
||||||
raise oscerr.WrongArgs('Too many arguments.')
|
apiurl,
|
||||||
|
project=project,
|
||||||
if len(args) == 0:
|
package=package,
|
||||||
if is_package_dir(Path.cwd()):
|
repository=opts.repo,
|
||||||
source_project = store_read_project(Path.cwd())
|
target_project=opts.target_project,
|
||||||
source_package = store_read_package(Path.cwd())
|
target_repository=opts.target_repository,
|
||||||
elif is_project_dir(Path.cwd()):
|
set_release_to=opts.set_release,
|
||||||
source_project = store_read_project(Path.cwd())
|
delayed=not opts.no_delay,
|
||||||
else:
|
print_to="stdout",
|
||||||
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))
|
|
||||||
|
|
||||||
@cmdln.option('-m', '--message', metavar='TEXT',
|
@cmdln.option('-m', '--message', metavar='TEXT',
|
||||||
help='specify message TEXT')
|
help='specify message TEXT')
|
||||||
|
Loading…
Reference in New Issue
Block a user