diff mbox series

[3/3] devtool: upgrade: clean up extracted changelog content

Message ID 20260512072446.2323529-4-daniel.turull@ericsson.com
State New
Headers show
Series devtool: add changelog extraction | expand

Commit Message

Daniel Turull May 12, 2026, 7:24 a.m. UTC
From: Daniel Turull <daniel.turull@ericsson.com>

Collapse runs of multiple blank lines into a single blank line and
strip leading/trailing whitespace from the extracted changelog. This
produces cleaner output that is suitable for inclusion in commit
messages by tools like AUH.

Assisted-by: kiro:claude-opus-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
---
 scripts/lib/devtool/upgrade.py | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index f2a2c8a6fb..e37ad07ea1 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -597,6 +597,11 @@  def _extract_changelog(srctree, pn, old_ver, new_ver, old_tag, new_tag, workspac
     if not changelog_content:
         return None
 
+    # Clean up content for readability and commit message use
+    changelog_content = re.sub(r'\n{3,}', '\n\n', changelog_content).strip()
+    if not changelog_content:
+        return None
+
     changelog_dir = os.path.join(workspace_path, 'changelogs')
     bb.utils.mkdirhier(changelog_dir)
     changelog_path = os.path.join(changelog_dir, '%s.txt' % pn)