You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:47:42 UTC

[buildstream] 10/10: buildstream/_frontend/cli.py: Add mirror command. tests/completions/completions.py: Add mirror command.

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch valentindavid/update_mirror
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 061fc2864181ed13e16a27c0370bf3cb99190c98
Author: Valentin David <va...@codethink.co.uk>
AuthorDate: Thu Apr 26 10:14:53 2018 +0200

    buildstream/_frontend/cli.py: Add mirror command.
    tests/completions/completions.py: Add mirror command.
---
 buildstream/_frontend/cli.py     | 48 ++++++++++++++++++++++++++++++++++++++++
 tests/completions/completions.py |  1 +
 2 files changed, 49 insertions(+)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 41e97cb..73c94ba 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -6,6 +6,7 @@ from .. import _yaml
 from .._exceptions import BstError, LoadError, AppError
 from .._versions import BST_FORMAT_VERSION
 from .complete import main_bashcomplete, complete_path, CompleteUnhandled
+from .. import utils
 
 
 ##################################################################
@@ -330,6 +331,53 @@ def track(app, elements, deps, except_, cross_junctions):
 
 
 ##################################################################
+#                         Mirror Command                         #
+##################################################################
+@cli.command(short_help="Mirror new source references")
+@click.option('--except', 'except_', multiple=True,
+              type=click.Path(dir_okay=False, readable=True),
+              help="Except certain dependencies from mirroring")
+@click.option('--deps', '-d', default='none',
+              type=click.Choice(['none', 'all']),
+              help='The dependencies to mirror (default: none)')
+@click.argument('elements', nargs=-1,
+                required=False,
+                type=click.Path(dir_okay=False, readable=True))
+@click.pass_obj
+def mirror(app, elements, deps, except_):
+    """Mirror all sources.
+
+    This will download everything available from sources. For
+    repositories, it will download all commits/revisions. For files,
+    it will download the latest version even if the source is already
+    cached. Previously mirrored/fetched downloads will still be
+    accessible.
+
+    If no element is given as parameters, all elements found in
+    `element_path` will be used.
+
+    Specify `--deps` to control which sources to track:
+
+    \b
+        none:  No dependencies, just the specified elements
+        all:   All dependencies of all specified elements
+
+    """
+    if not elements:
+        with app.partially_initialized():
+            elements = []
+            for element in utils.list_relative_paths(app.project.element_path):
+                if element.endswith('.bst'):
+                    elements.append(element)
+    elements = tuple(elements)
+
+    with app.initialized(session_name="Mirror"):
+        app.stream.mirror(elements,
+                          selection=deps,
+                          except_targets=except_)
+
+
+##################################################################
 #                           Pull Command                         #
 ##################################################################
 @cli.command(short_help="Pull a built artifact")
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index cc98cb9..47b13dc 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -10,6 +10,7 @@ MAIN_COMMANDS = [
     'checkout ',
     'fetch ',
     'init ',
+    'mirror ',
     'pull ',
     'push ',
     'shell ',