You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:47:27 UTC

[buildstream] 02/13: cli.py: Separate target and artifact ref completion

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

tvb pushed a commit to branch richardmaw/artifact-subcommands
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit adc8074638130436a193c7e76ec47e74b277bd78
Author: Richard Maw <ri...@codethink.co.uk>
AuthorDate: Wed Dec 12 18:11:36 2018 +0000

    cli.py: Separate target and artifact ref completion
    
    It doesn't make sense for operations such as listing the contents of the cache
    to list elements in the working tree,
    so generically completing artifacts as both artifact refs and element targets
    is unhelpful.
---
 buildstream/_frontend/cli.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 29fc4cf..222be1c 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -113,7 +113,7 @@ def complete_target(args, incomplete):
 
 def complete_artifact(args, incomplete):
     from .._context import Context
-    ctx = Context()
+    ctx = Context(read_only=True)
 
     config = None
     for i, arg in enumerate(args):
@@ -121,11 +121,7 @@ def complete_artifact(args, incomplete):
             config = args[i + 1]
     ctx.load(config)
 
-    # element targets are valid artifact names
-    complete_list = complete_target(args, incomplete)
-    complete_list.extend(ref for ref in ctx.artifactcache.cas.list_refs() if ref.startswith(incomplete))
-
-    return complete_list
+    return [ref for ref in ctx.artifactcache.cas.list_refs() if ref.startswith(incomplete)]
 
 
 def override_completions(cmd, cmd_param, args, incomplete):
@@ -150,7 +146,9 @@ def override_completions(cmd, cmd_param, args, incomplete):
                 cmd_param.opts == ['--track-except']):
             return complete_target(args, incomplete)
         if cmd_param.name == 'artifacts':
-            return complete_artifact(args, incomplete)
+            complete_list = complete_target(args, incomplete)
+            complete_list.extend(complete_artifact(args, incomplete))
+            return complete_list
 
     raise CompleteUnhandled()