Per Bazel query documentation
there is a function filter(pattern, input) which supposed to remove all items from "input" which do not satisfy the regular expression "pattern". Sounds simple enough, but still I struggle to understands the results I get from it.
For example, here is the query which does not filter anything (pattern is empty string:
bazel cquery filter('', kind(rule, deps(mytarget))) --notool_deps --noimplicit_deps
And here is the fragment of the output:
Pattern '//modules' nicely gives me everything starting with modules:
Here comes the question: what pattern shall I use to get all the packages from my current workspace and skip all external workspaces?
Local labels start with the two slashes and external ones start with @, so naturally I try to filter for '^//' and it returns me everything! Why?
On this page I learned that instead of ^ I can use \A as the beginning of the input, so I set my pattern to '\A//' It produces everything starting with //modules, //codegen, etc. but for the reason beyond my comprehension misses everything starting with //thirdparty! I am puzzled.
What is the magic word I don't know? Why empty filter let //thirdparty through, but '\A//' blocks it? Why ^ does not work? Help!