category with no apps should be ignored, even if defined in config

https://gitlab.com/fdroid/fdroidclient/-/issues/2619#note_1421280589

The test needed to change because the test index files contained category
definitions that were not ever used in the "copy tests/repo, generate java/gpg
keys, update, and gpgsign" test in tests/run-tests.
This commit is contained in:
Hans-Christoph Steiner 2023-06-07 15:57:58 +02:00
parent 2c566cf68f
commit 48559ecec5
9 changed files with 44 additions and 3 deletions

View file

@ -743,9 +743,16 @@ def make_v2(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_
if categories_used_by_apps and not output['repo'].get(CATEGORIES_CONFIG_NAME):
output['repo'][CATEGORIES_CONFIG_NAME] = dict()
# include definitions for "auto-defined" categories, e.g. just used in app metadata
for category in sorted(categories_used_by_apps):
if category not in output['repo'][CATEGORIES_CONFIG_NAME]:
output['repo'][CATEGORIES_CONFIG_NAME][category] = dict()
# do not include defined categories if no apps use them
for category in list(output['repo'].get(CATEGORIES_CONFIG_NAME, list())):
if category not in categories_used_by_apps:
del output['repo'][CATEGORIES_CONFIG_NAME][category]
msg = _('Category "{category}" defined but not used for any apps!')
logging.warning(msg.format(category=category))
entry = {}
entry["timestamp"] = repodict["timestamp"]