AlmaLinux change: Sort the changelog entries after merging to ensure the correct order of the changelog
This commit is contained in:
parent
d3c3bf3fd2
commit
6a68926d2b
@ -1,6 +1,6 @@
|
||||
From d128484a6502f76a2dc3f70551efbc880583c075 Mon Sep 17 00:00:00 2001
|
||||
From 40925bdbca94349ae42108e3d9ac4fb8c1513770 Mon Sep 17 00:00:00 2001
|
||||
From: eabdullin <ed.abdullin.1@gmail.com>
|
||||
Date: Wed, 30 Oct 2024 12:38:20 +0300
|
||||
Date: Fri, 6 Dec 2024 09:44:47 +0300
|
||||
Subject: [PATCH] Added AlmaLinux change identifier
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
@ -11,16 +11,16 @@ Therefore, the ability to identify AlmaLinux-specific changes was added, using t
|
||||
If this comment is used, the base release number of the package remains unchanged, but the suffix almalinux.{almalinux_release_number} is appended.
|
||||
The almalinux_release_number counter increments with each AlmaLinux-specific change to the package and resets upon version/release updates of the package.
|
||||
---
|
||||
rpmautospec/changelog.py | 2 +
|
||||
rpmautospec/magic_comments.py | 7 +-
|
||||
rpmautospec/pkg_history.py | 85 +++++++++++++++++++++-
|
||||
rpmautospec/subcommands/process_distgit.py | 9 ++-
|
||||
tests/rpmautospec/test_magic_comments.py | 1 +
|
||||
tests/rpmautospec/subcommands/test_process_distgit.py | 3 ++-
|
||||
6 files changed, 101 insertions(+), 6 deletions(-)
|
||||
rpmautospec/changelog.py | 2 +
|
||||
rpmautospec/magic_comments.py | 7 +-
|
||||
rpmautospec/pkg_history.py | 108 +++++++++++++++++-
|
||||
rpmautospec/subcommands/process_distgit.py | 9 +-
|
||||
.../subcommands/test_process_distgit.py | 3 +-
|
||||
tests/rpmautospec/test_magic_comments.py | 1 +
|
||||
6 files changed, 124 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/rpmautospec/changelog.py b/rpmautospec/changelog.py
|
||||
index cb3e74f..b123bbe 100644
|
||||
index cb3e74f..599df6f 100644
|
||||
--- a/rpmautospec/changelog.py
|
||||
+++ b/rpmautospec/changelog.py
|
||||
@@ -106,6 +106,8 @@ class ChangelogEntry(dict):
|
||||
@ -68,18 +68,26 @@ index d56086e..4c1c06c 100644
|
||||
- return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release)
|
||||
+ return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release, is_almalinux=is_almalinux)
|
||||
diff --git a/rpmautospec/pkg_history.py b/rpmautospec/pkg_history.py
|
||||
index 9dabf10..3524383 100644
|
||||
index 9dabf10..e0a80d3 100644
|
||||
--- a/rpmautospec/pkg_history.py
|
||||
+++ b/rpmautospec/pkg_history.py
|
||||
@@ -313,13 +313,61 @@ class PkgHistoryProcessor:
|
||||
@@ -20,6 +20,7 @@ except ImportError: # pragma: no cover
|
||||
from rpmautospec_core import AUTORELEASE_MACRO
|
||||
|
||||
import rpm
|
||||
+from functools import cmp_to_key
|
||||
|
||||
from .changelog import ChangelogEntry
|
||||
from .magic_comments import parse_magic_comments
|
||||
@@ -313,13 +314,61 @@ class PkgHistoryProcessor:
|
||||
)
|
||||
release_number = max(parent_release_numbers, default=0)
|
||||
|
||||
- if self.specfile.name in commit.tree:
|
||||
+ is_parent_almalinux = any(
|
||||
+ res.get("almalinux-release-number") for res in parent_results if res
|
||||
+ )
|
||||
+
|
||||
- if self.specfile.name in commit.tree:
|
||||
+ if (
|
||||
+ self.specfile.name in commit.tree
|
||||
+ and (
|
||||
@ -134,7 +142,7 @@ index 9dabf10..3524383 100644
|
||||
log.debug("\trelease_number: %s", release_number)
|
||||
|
||||
prerel_str = "0." if prerelease else ""
|
||||
@@ -410,6 +458,7 @@ class PkgHistoryProcessor:
|
||||
@@ -410,6 +459,7 @@ class PkgHistoryProcessor:
|
||||
"commitlog": commit.message,
|
||||
"epoch-version": commit_result["epoch-version"],
|
||||
"release-complete": commit_result["release-complete"],
|
||||
@ -142,11 +150,12 @@ index 9dabf10..3524383 100644
|
||||
}
|
||||
)
|
||||
|
||||
@@ -442,13 +491,17 @@ class PkgHistoryProcessor:
|
||||
@@ -442,13 +492,19 @@ class PkgHistoryProcessor:
|
||||
else:
|
||||
log.debug("\tno parent to follow")
|
||||
previous_changelog = ()
|
||||
+ second_parent = None
|
||||
+ is_almalinux = False
|
||||
for candidate in parent_results:
|
||||
if not candidate:
|
||||
continue
|
||||
@ -156,25 +165,35 @@ index 9dabf10..3524383 100644
|
||||
- break
|
||||
+ else:
|
||||
+ second_parent = candidate.get("changelog", ())
|
||||
+ if second_parent is not None:
|
||||
+ is_almalinux = any(entry['almalinux-release-complete'] for entry in second_parent)
|
||||
+ if second_parent is not None and is_almalinux:
|
||||
+ previous_changelog = self._add_missing_changes(previous_changelog, second_parent)
|
||||
|
||||
log.debug("\tskip_for_changelog: %s", skip_for_changelog)
|
||||
|
||||
@@ -461,6 +514,34 @@ class PkgHistoryProcessor:
|
||||
@@ -461,6 +517,54 @@ class PkgHistoryProcessor:
|
||||
|
||||
yield commit_result
|
||||
|
||||
+
|
||||
+ @staticmethod
|
||||
+ def _add_missing_changes(changelog1, changelog2):
|
||||
+ def add_unique_entries(entries, new_changelog, added_entries):
|
||||
+ for entry in entries:
|
||||
+ key = (entry['epoch-version'], entry['release-complete'], entry['almalinux-release-complete'])
|
||||
+ if key not in added_entries:
|
||||
+ new_changelog.append(entry)
|
||||
+ evra = (
|
||||
+ entry['epoch-version'].split(':', 1)[0] or "0",
|
||||
+ entry['epoch-version'].split(':', 1)[-1] or "0",
|
||||
+ entry['release-complete'] + entry['almalinux-release-complete']
|
||||
+ )
|
||||
+ new_changelog[evra] = entry
|
||||
+ added_entries.add(key)
|
||||
+
|
||||
+ new_changelog = []
|
||||
+ def compare_evra(a, b):
|
||||
+ return rpm.labelCompare(a, b)
|
||||
+
|
||||
+ new_changelog = {}
|
||||
+ added_entries = set()
|
||||
+
|
||||
+ max_release2 = changelog2[0]['release-complete']
|
||||
@ -184,20 +203,31 @@ index 9dabf10..3524383 100644
|
||||
+ key = (entry['epoch-version'], entry['release-complete'], entry['almalinux-release-complete'])
|
||||
+ if (entry['epoch-version'], entry['release-complete']) == (max_version2, max_release2):
|
||||
+ break
|
||||
+ new_changelog.append(entry)
|
||||
+ evra = (
|
||||
+ entry['epoch-version'].split(':', 1)[0] or "0",
|
||||
+ entry['epoch-version'].split(':', 1)[-1] or "0",
|
||||
+ entry['release-complete'] + entry['almalinux-release-complete']
|
||||
+ )
|
||||
+ new_changelog[evra] = entry
|
||||
+ added_entries.add(key)
|
||||
+
|
||||
+ add_unique_entries(changelog2, new_changelog, added_entries)
|
||||
+
|
||||
+ add_unique_entries(changelog1, new_changelog, added_entries)
|
||||
+
|
||||
+ return tuple(new_changelog)
|
||||
+ sorted_changelog = sorted(
|
||||
+ new_changelog.items(),
|
||||
+ key=cmp_to_key(lambda x, y: compare_evra(x[0], y[0])),
|
||||
+ reverse=True
|
||||
+ )
|
||||
+
|
||||
+ return tuple(entry for _, entry in sorted_changelog)
|
||||
+
|
||||
@staticmethod
|
||||
def _merge_info(f1: dict[str, Any], f2: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Merge dicts containing info of previously run visitors."""
|
||||
diff --git a/rpmautospec/subcommands/process_distgit.py b/rpmautospec/subcommands/process_distgit.py
|
||||
index 25a03f4..55b0fd1 100644
|
||||
index 25a03f4..760e4aa 100644
|
||||
--- a/rpmautospec/subcommands/process_distgit.py
|
||||
+++ b/rpmautospec/subcommands/process_distgit.py
|
||||
@@ -24,7 +24,7 @@ AUTORELEASE_TEMPLATE = """
|
||||
@ -225,18 +255,6 @@ index 25a03f4..55b0fd1 100644
|
||||
)
|
||||
used_features.append("autorelease")
|
||||
else:
|
||||
diff --git a/tests/rpmautospec/test_magic_comments.py b/tests/rpmautospec/test_magic_comments.py
|
||||
index 2801cd7..3938dcd 100644
|
||||
--- a/tests/rpmautospec/test_magic_comments.py
|
||||
+++ b/tests/rpmautospec/test_magic_comments.py
|
||||
@@ -26,6 +26,7 @@ def _read_commitlog_magic_comments_testdata():
|
||||
MagicCommentResult(
|
||||
skip_changelog=d.get("skip_changelog", False),
|
||||
bump_release=d.get("bump_release", 0),
|
||||
+ is_almalinux=d.get("is_almalinux", False),
|
||||
),
|
||||
id=f"commit-{variant}",
|
||||
)
|
||||
diff --git a/tests/rpmautospec/subcommands/test_process_distgit.py b/tests/rpmautospec/subcommands/test_process_distgit.py
|
||||
index d57d2df..7a9e972 100644
|
||||
--- a/tests/rpmautospec/subcommands/test_process_distgit.py
|
||||
@ -251,5 +269,17 @@ index d57d2df..7a9e972 100644
|
||||
print(
|
||||
process_distgit.RPMAUTOSPEC_TEMPLATE.format(
|
||||
version=__version__,
|
||||
diff --git a/tests/rpmautospec/test_magic_comments.py b/tests/rpmautospec/test_magic_comments.py
|
||||
index 2801cd7..3938dcd 100644
|
||||
--- a/tests/rpmautospec/test_magic_comments.py
|
||||
+++ b/tests/rpmautospec/test_magic_comments.py
|
||||
@@ -26,6 +26,7 @@ def _read_commitlog_magic_comments_testdata():
|
||||
MagicCommentResult(
|
||||
skip_changelog=d.get("skip_changelog", False),
|
||||
bump_release=d.get("bump_release", 0),
|
||||
+ is_almalinux=d.get("is_almalinux", False),
|
||||
),
|
||||
id=f"commit-{variant}",
|
||||
)
|
||||
--
|
||||
2.39.5 (Apple Git-154)
|
||||
|
Loading…
Reference in New Issue
Block a user