From: Herton R. Krzesinski <herton(a)redhat.com>
redhat: use tags from git notes for zstream to generate changelog
This is forwarded ported from current rhel-9/centos9 tree. Due lots
of recent changes in the ARK tree regarding Makefile and variables,
some changes had to be done to this: dropped variable changes/additions
to redhat/Makefile and redhat/genspec.sh, since those now are exported
from the Makefile; for the same reason, the usage of ZSTREAM_FLAG
variable was changed to the exported __ZSTREAM variable from the
Makefile.
From: Jan Stancek <jstancek(a)redhat.com>
Bugzilla: INTERNAL
Upstream Status: RHEL only
Conflicts: find_bz_in_line() is copied from rhel-8, because rhel-9 version
didn't support BZ id without URL
Forward-port of rhel-8 patch:
commit cc89787cb88591e92c73a2b4ee432d50f36c5108
Author: Frantisek Hrbata <fhrbata(a)redhat.com>
Date: Tue Mar 2 13:56:21 2021 +0100
redhat: use tags from git notes for zstream to generate changelog
Bugzilla: INTERNAL
Upstream Status: RHEL only
Tested: make rh-release for main and 8.3 branches and checked the
generated changelog
v2: - Use maj.min* notes ref for zstream. Previously only maj.min ref was
used. This change allows kernel-rt to use their notes along with the
zstream ones for rt specific patches.
Previously for zstream we amended commit messages while applying patches from
patchwork and we added tags: Bugzilla: ybzs, Z-Bugzilla: zbzs and CVE: cves
if necessary. These were used by the genspec.sh to generate
spec changelog for zstreams.
Keeping the same approach with the gitlab workflow would mean to rebase
commits in merge requests for zstream, which is something we probably
don't want in the merge oriented workflow. Other approach would be to
require these tags in the merge request commits. This would be fine for
MRs created by maintainers, but could be confusing for others while
creating zstream specific MRs. This would also require changes in
bugzilla webhook.
To avoid any additional requirements or changes in genlog.py, let's just
use git notes to store zstream tags. The change is that zstream
maintainer will not amend commit messages, but will be adding the
required tags to git notes. With this change we will feed genlog.py with
git notes instead of commit messages for zstreams. There should be no
change for ystream.
Each zstream is expected to have its own ref for notes based on the major
and minor version. For example refs/notes/8.3 for 8.3.z. It's expected
that maintainer makes sure the notes are presented and up-to-date.
Fetching them automatically is IMHO not safe, because we cannot know the
context.
The format in git notes should be the same as expected by genlog.py.
Bugzilla: ybzs
Z-Bugzilla: zbzs
CVE: cves
Signed-off-by: Frantisek Hrbata <fhrbata(a)redhat.com>
Signed-off-by: Jan Stancek <jstancek(a)redhat.com>
Signed-off-by: Herton R. Krzesinski <herton(a)redhat.com>
diff --git a/redhat/genlog.py b/redhat/genlog.py
index blahblah..blahblah 100755
--- a/redhat/genlog.py
+++ b/redhat/genlog.py
@@ -17,16 +17,18 @@ import sys
def find_bz_in_line(line, prefix):
"""Return bug number from properly formated Bugzilla:
line."""
- # BZs must begin with '{prefix}: ' and contain a complete BZ URL
- line = line.rstrip()
- pattern = prefix + r':
http(s)?://bugzilla\.redhat\.com/(show_bug\.cgi\?id=)?(?P<bug>\d{4,8})$'
- bznum_re = re.compile(pattern)
- bzn = set()
- match = bznum_re.match(line)
- if match:
- bzn.add(match.group('bug'))
- return bzn
-
+ # BZs must begin with '{prefix}: ' and contain a complete BZ URL or id
+ _bugs = set()
+ if not line.startswith(f"{prefix}: "):
+ return _bugs
+ bznum_re = re.compile(r'(?P<bug_ids> \d{4,8})|'
+ r'(
http(s)?://bugzilla\.redhat\.com/(show_bug\.cgi\?id=)?(?P<url_bugs>\d{4,8}))')
+ for match in bznum_re.finditer(line[len(f"{prefix}:"):]):
+ for group in [ 'bug_ids', 'url_bugs' ]:
+ if match.group(group):
+ bid = match.group(group).strip()
+ _bugs.add(bid)
+ return _bugs
def find_cve_in_line(line):
"""Return cve number from properly formated CVE:
line."""
diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -87,6 +87,13 @@ done
# test changes.
[ -n "$RHSELFTESTDATA" ] && exit 0
+GIT_FORMAT="--format=- %s (%an)%n%b"
+GIT_NOTES=""
+if [ "$__ZSTREAM" != "no" ]; then
+ GIT_FORMAT="--format=- %s (%an)%n%N"
+ GIT_NOTES="--notes=refs/notes/${RHEL_MAJOR}.${RHEL_MINOR}*"
+fi
+
echo > "$clogf"
lasttag=$(git rev-list --first-parent --grep="^\[redhat\]
kernel-${RPMKVERSION}.${RPMKPATCHLEVEL}" --max-count=1 HEAD)
@@ -103,7 +110,7 @@ fi
echo "Gathering new log entries since $lasttag"
# master is expected to track mainline.
-git log --topo-order --reverse --no-merges -z --format="- %s (%an)%n%b" \
+git log --topo-order --reverse --no-merges -z $GIT_NOTES "$GIT_FORMAT" \
^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' |
"${0%/*}"/genlog.py >> "$clogf"
grep -v "tagging $RPMVERSION" "$clogf" >
"$clogf.stripped"
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1764