Update patch to use with autopatch-tool
This commit is contained in:
parent
960ddb2b36
commit
88b42f0a7f
@ -6,7 +6,7 @@ actions:
|
|||||||
count: 1
|
count: 1
|
||||||
|
|
||||||
- modify_release:
|
- modify_release:
|
||||||
- suffix: ".alma.1"
|
- suffix: ".alma.3"
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
- changelog_entry:
|
- changelog_entry:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 40925bdbca94349ae42108e3d9ac4fb8c1513770 Mon Sep 17 00:00:00 2001
|
From 332637e14a68883cfbe61a39718d56df5daa991a Mon Sep 17 00:00:00 2001
|
||||||
From: eabdullin <ed.abdullin.1@gmail.com>
|
From: eabdullin <ed.abdullin.1@gmail.com>
|
||||||
Date: Fri, 6 Dec 2024 09:44:47 +0300
|
Date: Fri, 6 Dec 2024 09:44:47 +0300
|
||||||
Subject: [PATCH] Added AlmaLinux change identifier
|
Subject: [PATCH] Added AlmaLinux change identifier
|
||||||
@ -12,12 +12,12 @@ If this comment is used, the base release number of the package remains unchange
|
|||||||
The almalinux_release_number counter increments with each AlmaLinux-specific change to the package and resets upon version/release updates of the package.
|
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/changelog.py | 2 +
|
||||||
rpmautospec/magic_comments.py | 7 +-
|
rpmautospec/magic_comments.py | 7 ++-
|
||||||
rpmautospec/pkg_history.py | 108 +++++++++++++++++-
|
rpmautospec/pkg_history.py | 52 ++++++++++++++++++-
|
||||||
rpmautospec/subcommands/process_distgit.py | 9 +-
|
rpmautospec/subcommands/process_distgit.py | 9 +++-
|
||||||
.../subcommands/test_process_distgit.py | 3 +-
|
.../subcommands/test_process_distgit.py | 3 +-
|
||||||
tests/rpmautospec/test_magic_comments.py | 1 +
|
tests/rpmautospec/test_magic_comments.py | 1 +
|
||||||
6 files changed, 124 insertions(+), 6 deletions(-)
|
6 files changed, 69 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
diff --git a/rpmautospec/changelog.py b/rpmautospec/changelog.py
|
diff --git a/rpmautospec/changelog.py b/rpmautospec/changelog.py
|
||||||
index cb3e74f..599df6f 100644
|
index cb3e74f..599df6f 100644
|
||||||
@ -68,31 +68,18 @@ index d56086e..4c1c06c 100644
|
|||||||
- return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release)
|
- return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release)
|
||||||
+ return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release, is_almalinux=is_almalinux)
|
+ 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
|
diff --git a/rpmautospec/pkg_history.py b/rpmautospec/pkg_history.py
|
||||||
index 9dabf10..e0a80d3 100644
|
index 9dabf10..bfa1f6b 100644
|
||||||
--- a/rpmautospec/pkg_history.py
|
--- a/rpmautospec/pkg_history.py
|
||||||
+++ b/rpmautospec/pkg_history.py
|
+++ b/rpmautospec/pkg_history.py
|
||||||
@@ -20,6 +20,7 @@ except ImportError: # pragma: no cover
|
@@ -313,13 +313,55 @@ class PkgHistoryProcessor:
|
||||||
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)
|
release_number = max(parent_release_numbers, default=0)
|
||||||
|
|
||||||
- if self.specfile.name in commit.tree:
|
- if self.specfile.name in commit.tree:
|
||||||
+ is_parent_almalinux = any(
|
|
||||||
+ res.get("almalinux-release-number") for res in parent_results if res
|
|
||||||
+ )
|
|
||||||
+
|
|
||||||
+ if (
|
+ if (
|
||||||
+ self.specfile.name in commit.tree
|
+ self.specfile.name in commit.tree
|
||||||
+ and (
|
+ and (
|
||||||
+ not commit_result["magic-comment-result"].is_almalinux and
|
+ not commit_result["magic-comment-result"].is_almalinux
|
||||||
+ not is_parent_almalinux
|
|
||||||
+ )
|
+ )
|
||||||
+ ):
|
+ ):
|
||||||
release_number += 1
|
release_number += 1
|
||||||
@ -102,11 +89,11 @@ index 9dabf10..e0a80d3 100644
|
|||||||
commit_result["release-number"] = release_number
|
commit_result["release-number"] = release_number
|
||||||
|
|
||||||
+ is_almalinux_commit = (
|
+ is_almalinux_commit = (
|
||||||
+ commit_result["magic-comment-result"].is_almalinux or is_parent_almalinux
|
+ commit_result["magic-comment-result"].is_almalinux
|
||||||
+ )
|
+ )
|
||||||
+
|
+
|
||||||
+ if is_almalinux_commit:
|
+ if is_almalinux_commit:
|
||||||
+ log.debug("\tHas AlmaLinux changes or parent Almalinux release")
|
+ log.debug("\tHas AlmaLinux changes")
|
||||||
+
|
+
|
||||||
+ parent_almalinux_release_numbers = tuple(
|
+ parent_almalinux_release_numbers = tuple(
|
||||||
+ (
|
+ (
|
||||||
@ -124,8 +111,7 @@ index 9dabf10..e0a80d3 100644
|
|||||||
+ almalinux_release_number += 1
|
+ almalinux_release_number += 1
|
||||||
+
|
+
|
||||||
+ if (
|
+ if (
|
||||||
+ release_number > max(parent_release_numbers, default=0) or
|
+ release_number > max(parent_release_numbers, default=0)
|
||||||
+ (is_parent_almalinux and len(commit.parents) > 1)
|
|
||||||
+ ):
|
+ ):
|
||||||
+ almalinux_release_number = 1
|
+ almalinux_release_number = 1
|
||||||
+ elif epoch_version != commit_verflags.get("epoch-version"):
|
+ elif epoch_version != commit_verflags.get("epoch-version"):
|
||||||
@ -142,7 +128,18 @@ index 9dabf10..e0a80d3 100644
|
|||||||
log.debug("\trelease_number: %s", release_number)
|
log.debug("\trelease_number: %s", release_number)
|
||||||
|
|
||||||
prerel_str = "0." if prerelease else ""
|
prerel_str = "0." if prerelease else ""
|
||||||
@@ -410,6 +459,7 @@ class PkgHistoryProcessor:
|
@@ -384,6 +426,10 @@ class PkgHistoryProcessor:
|
||||||
|
# care. If it didn't change, we don't know how to continue and need to flag that.
|
||||||
|
merge_unresolvable = not changelog_changed
|
||||||
|
|
||||||
|
+ if merge_unresolvable and commit.message.lower().startswith("almalinux changes:"):
|
||||||
|
+ merge_unresolvable = False
|
||||||
|
+ parent_to_follow = commit.parents[1]
|
||||||
|
+
|
||||||
|
our_child_must_continue = (
|
||||||
|
not (changelog_changed and changelog_blob or merge_unresolvable) and child_must_continue
|
||||||
|
)
|
||||||
|
@@ -410,6 +456,7 @@ class PkgHistoryProcessor:
|
||||||
"commitlog": commit.message,
|
"commitlog": commit.message,
|
||||||
"epoch-version": commit_result["epoch-version"],
|
"epoch-version": commit_result["epoch-version"],
|
||||||
"release-complete": commit_result["release-complete"],
|
"release-complete": commit_result["release-complete"],
|
||||||
@ -150,82 +147,16 @@ index 9dabf10..e0a80d3 100644
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -442,13 +492,19 @@ class PkgHistoryProcessor:
|
@@ -452,6 +499,9 @@ 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
|
|
||||||
if candidate["commit-id"] == parent_to_follow.id:
|
|
||||||
previous_changelog = candidate.get("changelog", ())
|
|
||||||
skip_for_changelog = True
|
|
||||||
- break
|
|
||||||
+ else:
|
|
||||||
+ second_parent = candidate.get("changelog", ())
|
|
||||||
+ 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)
|
log.debug("\tskip_for_changelog: %s", skip_for_changelog)
|
||||||
|
|
||||||
@@ -461,6 +517,54 @@ class PkgHistoryProcessor:
|
+ if skip_for_changelog and commit.message.lower().startswith("almalinux changes:"):
|
||||||
|
+ skip_for_changelog = False
|
||||||
|
+
|
||||||
|
changelog_entry["skip"] = skip_for_changelog
|
||||||
|
|
||||||
yield commit_result
|
if not skip_for_changelog:
|
||||||
|
|
||||||
+
|
|
||||||
+ @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:
|
|
||||||
+ 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)
|
|
||||||
+
|
|
||||||
+ def compare_evra(a, b):
|
|
||||||
+ return rpm.labelCompare(a, b)
|
|
||||||
+
|
|
||||||
+ new_changelog = {}
|
|
||||||
+ added_entries = set()
|
|
||||||
+
|
|
||||||
+ max_release2 = changelog2[0]['release-complete']
|
|
||||||
+ max_version2 = changelog2[0]['epoch-version']
|
|
||||||
+
|
|
||||||
+ for entry in changelog1:
|
|
||||||
+ key = (entry['epoch-version'], entry['release-complete'], entry['almalinux-release-complete'])
|
|
||||||
+ if (entry['epoch-version'], entry['release-complete']) == (max_version2, max_release2):
|
|
||||||
+ break
|
|
||||||
+ 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)
|
|
||||||
+
|
|
||||||
+ 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
|
diff --git a/rpmautospec/subcommands/process_distgit.py b/rpmautospec/subcommands/process_distgit.py
|
||||||
index 25a03f4..760e4aa 100644
|
index 25a03f4..760e4aa 100644
|
||||||
--- a/rpmautospec/subcommands/process_distgit.py
|
--- a/rpmautospec/subcommands/process_distgit.py
|
||||||
@ -283,3 +214,4 @@ index 2801cd7..3938dcd 100644
|
|||||||
)
|
)
|
||||||
--
|
--
|
||||||
2.39.5 (Apple Git-154)
|
2.39.5 (Apple Git-154)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user