Commit 3183d9e7 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[commands] Implement push "history" of an asset

This means push the versions or forks it came from.

This is currently recursive so it should go back to
the original and start pushing from there.
parent 11a1a940
......@@ -270,19 +270,35 @@ def push_impl(ctx, names, force, dry_run):
$ beat algorithms push --dry-run yyy
"""
def do_push(ctx, dependency_type, names):
push_cmd = main_cli.main.get_command(ctx, dependency_type).get_command(
ctx, "push"
)
ctx.meta["asset_info"] = push_cmd.asset_info
return ctx.invoke(push_cmd, names=names, force=force, dry_run=dry_run)
config = ctx.meta["config"]
asset_info = ctx.meta["asset_info"]
mappings = ctx.meta.get("mappings", {})
if asset_info.get_dependencies is not None:
for name in names:
for name in names:
with common.Selector(config.path) as selector:
dependency_type = common.TYPE_PLURAL[asset_info.asset_type]
fork = selector.forked_from(asset_info.asset_type, name)
if fork:
status = do_push(ctx, dependency_type, [fork])
if status != 0:
return status
version = selector.version_of(asset_info.asset_type, name)
if version:
status = do_push(ctx, dependency_type, [version])
if status != 0:
return status
if asset_info.get_dependencies is not None:
dependencies = asset_info.get_dependencies(ctx, name)
for dependency_type, dependency_list in dependencies.items():
push_cmd = main_cli.main.get_command(ctx, dependency_type).get_command(
ctx, "push"
)
ctx.meta["asset_info"] = push_cmd.asset_info
status = ctx.invoke(push_cmd, names=dependency_list)
status = do_push(ctx, dependency_type, dependency_list)
if status != 0:
return status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment