diff --git a/custom_components/hacs/repositories/base.py b/custom_components/hacs/repositories/base.py index 950f52facd3..e07c43ad9dd 100644 --- a/custom_components/hacs/repositories/base.py +++ b/custom_components/hacs/repositories/base.py @@ -1183,6 +1183,9 @@ def gather_files_to_download(self) -> list[FileInformation]: for release in releaseobjects or []: if ref == release.tag_name: for asset in release.assets or []: + # For themes, only download .yaml files from release assets + if category == "theme" and not asset.name.endswith(".yaml"): + continue files.append( FileInformation(asset.browser_download_url, asset.name, asset.name) ) diff --git a/tests/helpers/download/test_gather_files_to_download.py b/tests/helpers/download/test_gather_files_to_download.py index 18d268765df..3c549f3777c 100644 --- a/tests/helpers/download/test_gather_files_to_download.py +++ b/tests/helpers/download/test_gather_files_to_download.py @@ -230,4 +230,28 @@ def test_gather_plugin_different_card_name(repository_plugin): repository_plugin.update_filenames() files = [x.path for x in repository.gather_files_to_download()] assert "card.js" in files + + def test_gather_theme_files_from_release_only_yaml(repository_theme): + """Test that only .yaml files are downloaded from theme release assets.""" + repository = repository_theme + repository.ref = "1.0.0" + repository.data.releases = True + repository.releases.objects = [ + GitHubReleaseModel({ + "tag_name": "1.0.0", + "assets": [ + {"name": "theme.yaml"}, + {"name": "theme-dark.yaml"}, + {"name": "screenshot.png"}, + {"name": "README.md"}, + {"name": "theme.zip"}, + ] + }), + ] + files = [x.name for x in repository.gather_files_to_download()] + assert "theme.yaml" in files + assert "theme-dark.yaml" in files + assert "screenshot.png" not in files + assert "README.md" not in files + assert "theme.zip" not in files assert "info.md" not in files