Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow -fo in conan list to use &: scope to refer to all packages being listed #16559

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conan/api/subapi/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def filter_packages_profile(packages, profile, ref):
options = data.get("options", {})
for k, v in options.items():
for pattern, pattern_options in profile_options.items():
if ref_matches(ref, pattern, None):
# Accept &: as referring to the current package being listed,
# even if it's not technically a "consumer"
if ref_matches(ref, pattern, True):
value = pattern_options.get_safe(k)
if value is not None and value != v:
options_match = False
Expand Down
10 changes: 10 additions & 0 deletions test/integration/command_v2/list_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,3 +896,13 @@ def test_list_filter(self, remote):
assert len(pkg["packages"]) == 1
settings = pkg["packages"]["d2e97769569ac0a583d72c10a37d5ca26de7c9fa"]["info"]["settings"]
assert settings == {"arch": "x86", "os": "Windows"}

# &: will also match every package being listed, as if it was a consumer
c.run(f"list *:* -fo &:shared=False --format=json {r}")
result = json.loads(c.stdout)
header = result[pkg_key]["header/1.0"]["revisions"]["747cc49983b14bdd00df50a0671bd8b3"]
assert header["packages"] == {"da39a3ee5e6b4b0d3255bfef95601890afd80709": {"info": {}}}
pkg = result[pkg_key]["pkg/1.0"]["revisions"]["03591c8b22497dd74214e08b3bf2a56f"]
assert len(pkg["packages"]) == 2
settings = pkg["packages"]["d2e97769569ac0a583d72c10a37d5ca26de7c9fa"]["info"]["settings"]
assert settings == {"arch": "x86", "os": "Windows"}