From b071406c7e326cc07825ba0de5e2896ed1f89901 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Tue, 18 Jan 2022 14:04:55 -0500 Subject: [PATCH] Small adjustments to changelog limiting Sort the changelog entries by date first. I was hoping this wasn't necessary since both legacy createrepo and createrepo_c use a specific order, but I discovered that Oracle Linux used to use reverse chronological order. I have no idea what tool they used but lets play it safe for now closes #2363 https://github.com/pulp/pulp_rpm/issues/2363 (cherry picked from commit cd7fc1402f5bd7bfffbe162f760df0e9490139c8) --- CHANGES/2363.bugfix | 1 + pulp_rpm/app/metadata_parsing.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 CHANGES/2363.bugfix diff --git a/CHANGES/2363.bugfix b/CHANGES/2363.bugfix new file mode 100644 index 000000000..7c712d6b6 --- /dev/null +++ b/CHANGES/2363.bugfix @@ -0,0 +1 @@ +Fixed an edge case with the changelog limit. diff --git a/pulp_rpm/app/metadata_parsing.py b/pulp_rpm/app/metadata_parsing.py index 060e3274a..600685a00 100644 --- a/pulp_rpm/app/metadata_parsing.py +++ b/pulp_rpm/app/metadata_parsing.py @@ -126,6 +126,9 @@ def process_other_package_element(element): text = subelement.text changelogs.append((author, date, text)) + # make sure the changelogs are sorted by date + changelogs.sort(key=lambda t: t[1]) + if settings.KEEP_CHANGELOG_LIMIT is not None: # always keep at least one changelog, even if the limit is set to 0 changelog_limit = settings.KEEP_CHANGELOG_LIMIT or 1