Skip to contentSkip to conversation

steps: read changelog through devtool's metadata file

PATCH In review [email protected] 2 participants 3 messages Oct 30 – Nov 3

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 steps: read changelog through devtool's metadata file

From: Daniel Turull <[email protected]>

devtool upgrade describes the changelog it extracted in workspace/changelogs/<pn>.json, including the name of the changelog file. Load that once per recipe into pkg_ctx and get the changelog text through it, so AUH relies on what devtool reports instead of guessing the changelog file name.

A missing metadata file means no changelog, as with releases whose devtool does not extract changelogs. Any other failure to read the metadata or the changelog it points to is an error.

Assisted-by kiro:claude-sonnet-5.5

---
Changes in v5:
- Store the metadata in pkg_ctx['devtool_upgrade_metadata'] via _get_devtool_json() and read the text with _get_changelog_text() (Alexander)
- Read the metadata and the changelog only once per recipe
- Only a missing metadata file is tolerated; other errors are no longer suppressed (Alexander)
Changes in v4:
- Load <pn>.json once, expose its fields in pkg_ctx with a devtool_ prefix and get the changelog through the changelog_file field
Changes in v3:
- New patch: refactor split out of "steps: skip changelog in commit message when devtool flags it"

---
 modules/steps.py | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)
modules/steps.py +24 -17
index e678a4b..3da8984 100644
@@ -19,6 +19,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #
 
+import json
 import os
 import shutil
 import re
@@ -80,20 +81,23 @@ def _make_commit_msg(group):
     versions = list(dict.fromkeys(_get_version(p) for p in group['pkgs']))
     return "{}: upgrade {}".format(pn, ",".join(versions))
 
-def _get_changelog(pn, workdir):
-    """Read the changelog generated by devtool upgrade and copy it to workdir.
-    Returns the changelog text or None."""
-    changelog_path = os.path.join(os.environ.get('BUILDDIR', ''),
-                                  'workspace', 'changelogs', '{}.txt'.format(pn))
-    if os.path.isfile(changelog_path):
-        try:
-            with open(changelog_path, 'r', encoding='utf-8', errors='replace') as f:
-                text = f.read()
-            shutil.copy2(changelog_path, os.path.join(workdir, '{}-changelog.txt'.format(pn)))
-            return text
-        except OSError as e:
-            W('Failed to copy changelog for {}: {}'.format(pn, e))
-    return None
+def _get_devtool_json(pn):
+    """Return the metadata devtool upgrade wrote for pn, or None if there
+    is none (no changelog found, or devtool without changelog support)."""
+    path = os.path.join(os.environ.get('BUILDDIR', ''),
+                        'workspace', 'changelogs', '{}.json'.format(pn))
+    if not os.path.exists(path):
+        return None
+    with open(path, 'r', encoding='utf-8') as f:
+        return json.load(f)
+
+
+def _get_changelog_text(metadata):
+    """Return the changelog text described by devtool upgrade metadata."""
+    path = os.path.join(os.environ.get('BUILDDIR', ''),
+                        'workspace', 'changelogs', metadata['changelog_file'])
+    with open(path, 'r', encoding='utf-8', errors='replace') as f:
+        return f.read()
 
 
 def _append_changelog_to_commit_msg(group, opts):
@@ -119,9 +123,12 @@ def _devtool_upgrade(devtool, bb, git, opts, pkg_ctx, workdir):
         devtool_output = devtool.upgrade(pkg_ctx['PN'], pkg_ctx['NPV'], pkg_ctx['NSRCREV'])
         D(" 'devtool upgrade' printed:\n%s" %(devtool_output))
         # Copy changelog before checking for conflicts — it's useful even on failure
-        changelog_text = _get_changelog(pkg_ctx['PN'], workdir)
-        if changelog_text:
-            pkg_ctx['changelog_text'] = changelog_text
+        pkg_ctx['devtool_upgrade_metadata'] = _get_devtool_json(pkg_ctx['PN'])
+        if pkg_ctx['devtool_upgrade_metadata']:
+            pkg_ctx['changelog_text'] = _get_changelog_text(pkg_ctx['devtool_upgrade_metadata'])
+            with open(os.path.join(workdir, '{}-changelog.txt'.format(pkg_ctx['PN'])),
+                      'w', encoding='utf-8') as f:
+                f.write(pkg_ctx['changelog_text'])
         # If devtool failed to rebase patches, it does not fail, but we should
         if 'conflict' in devtool_output:
             raise DevtoolError("Running 'devtool upgrade' for recipe %s failed." %(pkg_ctx['PN']), devtool_output)
#1 lore raw

PATCH v5 2/2 steps: skip changelog in commit message when devtool flags it

From: Daniel Turull <[email protected]>

Some upstream changelogs are badly formed for a commit message (e.g. mesa, gstreamer release notes, raw git log dumps) and make the upgrade commits hard to read. 'devtool upgrade' now flags these, driven by RECIPE_UPGRADE_CHANGELOG_SKIP in OE-Core, so honour that and leave them out of the commit message. The changelog is still attached to the AUH email, so the information is not lost.

This depends on the OE-Core patch "devtool: upgrade: flag badly formed changelogs in metadata".

Assisted-by kiro:claude-sonnet-5.5

---
Changes in v5:
- Use pkg_ctx['devtool_upgrade_metadata'] from the previous patch Changes in v4:
- Use the devtool_changelog_skip field exposed in pkg_ctx by the previous patch (Alexander)
Changes in v3:
- Parse the devtool metadata JSON once and keep it in pkg_ctx['changelog_metadata'] instead of reading it in a separate _changelog_skip() helper (Alexander)
- Split the _get_changelog() refactor into a separate patch

---
 modules/steps.py | 4 ++++
 1 file changed, 4 insertions(+)
modules/steps.py +4 -0
index 3da8984..9dc637f 100644
@@ -106,6 +106,10 @@ def _append_changelog_to_commit_msg(group, opts):
     for p in group['pkgs']:
         if 'changelog_text' not in p:
             continue
+        # Changelog stays attached to the email, only the commit message skips it
+        if p['devtool_upgrade_metadata'].get('changelog_skip'):
+            I(" %s: changelog not added to commit message (RECIPE_UPGRADE_CHANGELOG_SKIP)" % p['PN'])
+            continue
         text = p['changelog_text'].strip()
         # Group recipes may share a source and produce identical changelogs
         # (e.g. mesa, mesa-native); skip proven duplicates, keep the rest.
#2 lore raw

Re: [AUH][PATCH v5 2/2] steps: skip changelog in commit message when devtool flags it

Thanks, both patches applied and pushed.

Alex

Quoted 48 lines · On Fri, 30 Oct 2026 at 11:39, <[email protected]> wrote:

From: Daniel Turull <[email protected]>

Some upstream changelogs are badly formed for a commit message (e.g. mesa, gstreamer release notes, raw git log dumps) and make the upgrade commits hard to read. 'devtool upgrade' now flags these, driven by RECIPE_UPGRADE_CHANGELOG_SKIP in OE-Core, so honour that and leave them out of the commit message. The changelog is still attached to the AUH email, so the information is not lost.

This depends on the OE-Core patch "devtool: upgrade: flag badly formed changelogs in metadata".

Assisted-by kiro:claude-sonnet-5.5

---
Changes in v5:
- Use pkg_ctx['devtool_upgrade_metadata'] from the previous patch Changes in v4:
- Use the devtool_changelog_skip field exposed in pkg_ctx by the previous patch (Alexander)
Changes in v3:
- Parse the devtool metadata JSON once and keep it in pkg_ctx['changelog_metadata'] instead of reading it in a separate _changelog_skip() helper (Alexander)
- Split the _get_changelog() refactor into a separate patch

---
 modules/steps.py | 4 ++++
 1 file changed, 4 insertions(+)
modules/steps.py +1 -0
index 3da8984..9dc637f 100644
@@ -106,6 +106,10 @@ def _append_changelog_to_commit_msg(group, opts):
     for p in group['pkgs']:
         if 'changelog_text' not in p:
             continue
+        # Changelog stays attached to the email, only the commit message

skips it

modules/steps.py +2 -0
+        if p['devtool_upgrade_metadata'].get('changelog_skip'):
+            I(" %s: changelog not added to commit message

(RECIPE_UPGRADE_CHANGELOG_SKIP)" % p['PN'])
+ continue
text = p['changelog_text'].strip()
# Group recipes may share a source and produce identical
changelogs
# (e.g. mesa, mesa-native); skip proven duplicates, keep the rest.