This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch jennis/new_artifact_subcommands in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit ab6740f9b34e773b512370fd05d9d112e4347d38 Author: Richard Maw <[email protected]> AuthorDate: Wed Dec 12 18:37:53 2018 +0000 cli: Add artifact delete subcommand --- buildstream/_frontend/cli.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index b3e48d5..28e6027 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -1080,6 +1080,36 @@ def artifact_log(app, artifacts): click.echo_via_pager(data) +################################################################### +# Artifact Delete Command # +################################################################### [email protected](name='delete', short_help="Delete matching artifacts") [email protected]('artifacts', type=click.Path(), nargs=-1) [email protected]_obj +def artifact_delete(app, artifacts): + '''Delete matching artifacts from the cache''' + from .._pipeline import PipelineSelection + + with app.initialized(): + cache = app.context.artifactcache + + elements, artifacts = _classify_artifacts(artifacts, cache.cas, + app.project.directory) + + if not elements and not artifacts: + element = app.context.guess_element() + if element is not None: + elements = [element] + + if elements: + elements = app.stream.load_selection(elements, selection=PipelineSelection.NONE) + for element in elements: + cache.remove(cache.get_artifact_fullname(element, element._get_cache_key())) + if artifacts: + for i, ref in enumerate(artifacts, start=1): + cache.cas.remove(ref, defer_prune=(i != len(artifacts))) + + ################################################################## # DEPRECATED Commands # ##################################################################
