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

[upload] Ignore metadata when passing empty string #15007

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 15 additions & 1 deletion conan/internal/upload_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ def _metadata_files(folder, metadata):
return result


def gather_metadata(package_list, cache, metadata):
def gather_metadata(package_list, cache, metadata: list):
"""
List and configure the metadata files to be uploaded.
The metadata supports patterns, so it can be used to upload only a subset of the metadata files.
When metadata is not specified, all metadata files are uploaded.
But, when metadata is empty string (""), it means that no metadata files should be uploaded.

:param package_list: Package to be uploaded
:param cache: Conan client cache
:param metadata: A list of patterns of metadata that should be uploaded. Default None
"""

if metadata == ['']:
uilianries marked this conversation as resolved.
Show resolved Hide resolved
return

for rref, recipe_bundle in package_list.refs().items():
if metadata or recipe_bundle["upload"]:
metadata_folder = cache.recipe_layout(rref).metadata()
Expand Down
22 changes: 22 additions & 0 deletions conans/test/integration/metadata/test_metadata_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,25 @@ def test_no_download_cached(self):
assert "mylogs2!!!!" in mylogs
mybuildlogs = load(os.path.join(c2_pkg_metadata_path, "logs", "mybuildlogs.txt"))
assert "mybuildlogs2!!!!" in mybuildlogs

def test_upload_ignored_metadata(self):
"""
Upload command should ignore metadata files when passing --metadata=""
"""
client = TestClient(default_server_user=True)
client.save({"conanfile.py": GenConanfile("pkg", "0.1")})
client.run("create .")
pid = client.created_package_id("pkg/0.1")

def _save_metadata(client, ref):
client.run(f"cache path {ref} --folder=metadata")
metadata_path = str(client.stdout).strip()
myfile = os.path.join(metadata_path, "logs", "somefile.log")
save(myfile, ref)

_save_metadata(client, "pkg/0.1")
_save_metadata(client, f"pkg/0.1:{pid}")

client.run('upload * --confirm --remote=default --metadata=""')
assert "Recipe metadata" not in client.out
assert "Package metadata" not in client.out