devtool: add changelog extraction
cover devtool: add changelog extraction
From: Daniel Turull <[email protected]>
This series aims to extract the changelog between 2 versions when devtool is upgrade. The aim is that later to backport the feature into LTS branches, so we can have more detailed descriptions with AUH.
For testing I reverted the last 200 updates of recipes and master and try to do devtool upgrade <recipe> --no-patch, since I'm only interested in the changelog output.
From the last run: 83 with changelog, 21 without, 41 failed.
Excluding failures: 83 out of 104 = 80% of changelog were generated.
Daniel Turull (3):
devtool: upgrade: extract changelog between versions
devtool: upgrade: detect per-version release notes files
devtool: upgrade: clean up extracted changelog content
meta/lib/oeqa/selftest/cases/devtool.py | 24 +++++++ scripts/lib/devtool/standard.py | 8 +++ scripts/lib/devtool/upgrade.py | 95 +++++++++++++++++++++++++ 3 files changed, 127 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/3 devtool: upgrade: extract changelog between versions
From: Daniel Turull <[email protected]>
Automatically extract changelog information when upgrading a recipe. Uses the devtool-base tags created during upgrade to diff known changelog files (NEWS, ChangeLog, CHANGES, etc.) between the old and new versions. For git-based sources, falls back to git log --oneline if no changelog file changed.
Output is written to workspace/changelogs/<pn>.txt and cleaned up on devtool reset. This allows AUH and other tools to pick up the changelog without implementing their own extraction logic.
--- meta/lib/oeqa/selftest/cases/devtool.py | 24 +++++++ scripts/lib/devtool/standard.py | 8 +++ scripts/lib/devtool/upgrade.py | 84 +++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
meta/lib/oeqa/selftest/cases/devtool.py +24 -0
@@ -2028,6 +2028,30 @@ class DevtoolUpgradeTests(DevtoolBase): def test_devtool_upgrade_gitsm(self): self._test_devtool_upgrade_git_by_recipe('devtool-upgrade-test5', '0a60d6af95d22b4c50446559cd41942a8acd2d57') + def test_devtool_upgrade_changelog(self): + # Check preconditions + self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') + self.track_for_cleanup(self.workspacedir) + self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') + # dbus-wait has ChangeLog/NEWS files and one commit between these revisions + recipe = 'devtool-upgrade-test2' + commit = '6cc6077a36fe2648a5f993fe7c16c9632f946517' + tempdir = tempfile.mkdtemp(prefix='devtoolqa') + self.track_for_cleanup(tempdir) + # Perform upgrade + runCmd('devtool upgrade %s %s -S %s' % (recipe, tempdir, commit)) + # Check changelog file was created with expected content + changelog_file = os.path.join(self.workspacedir, 'changelogs', '%s.txt' % recipe) + self.assertExists(changelog_file, 'Changelog file should exist after upgrade') + with open(changelog_file, 'r') as f: + content = f.read() + self.assertIn(recipe, content) + # The commit between versions fixes a typo - verify we got real content + self.assertIn('typo', content) + # Check devtool reset cleans up changelog + runCmd('devtool reset %s -n' % recipe) + self.assertNotExists(changelog_file, 'Changelog file should be removed after reset') + def test_devtool_upgrade_drop_md5sum(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory')
scripts/lib/devtool/standard.py +8 -0
@@ -2046,6 +2046,14 @@ def _reset(recipes, no_clean, remove_work, config, basepath, workspace): clean_preferred_provider(pn, config.workspace_path) + # Clean up changelog if present + changelog_file = os.path.join(config.workspace_path, 'changelogs', '%s.txt' % pn) + if os.path.exists(changelog_file): + os.remove(changelog_file) + changelog_dir = os.path.dirname(changelog_file) + if not os.listdir(changelog_dir): + os.rmdir(changelog_dir) + def reset(args, config, basepath, workspace): """Entry point for the devtool 'reset' subcommand"""
scripts/lib/devtool/upgrade.py +84 -0
108 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [OE-core] [PATCH 1/3] devtool: upgrade: extract changelog between versions
Quoted 9 lines · Daniel Turull via lists.openembedded.org
Automatically extract changelog information when upgrading a recipe. Uses the devtool-base tags created during upgrade to diff known changelog files (NEWS, ChangeLog, CHANGES, etc.) between the old and new versions. For git-based sources, falls back to git log --oneline if no changelog file changed.
Output is written to workspace/changelogs/<pn>.txt and cleaned up on devtool reset. This allows AUH and other tools to pick up the changelog without implementing their own extraction logic.
Thanks, I like this a lot, and I think this should be fairly easy to get merged. Just a couple notes:
- probably patches 2/3 and 3/3 should all be folded into the main commit? (but also add those commit messages to the main commit message, don't discard the additional information)
- please see below this about testing the functionality
Quoted 13 lines
meta/lib/oeqa/selftest/cases/devtool.py +13
-0+ def test_devtool_upgrade_changelog(self): + # Check preconditions + self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') + self.track_for_cleanup(self.workspacedir) + self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') + # dbus-wait has ChangeLog/NEWS files and one commit between these revisions + recipe = 'devtool-upgrade-test2' + commit = '6cc6077a36fe2648a5f993fe7c16c9632f946517' + tempdir = tempfile.mkdtemp(prefix='devtoolqa') + self.track_for_cleanup(tempdir) + # Perform upgrade + runCmd('devtool upgrade %s %s -S %s' % (recipe, tempdir, commit)) + # Check changelog file was created with expected content
meta/lib/oeqa/selftest/cases/devtool.py class DevtoolUpgradeTests(DevtoolBase): · line 2053
Quoted 10 lines
meta/lib/oeqa/selftest/cases/devtool.py +10
-0+ changelog_file = os.path.join(self.workspacedir, 'changelogs', '%s.txt' % recipe) + self.assertExists(changelog_file, 'Changelog file should exist after upgrade') + with open(changelog_file, 'r') as f: + content = f.read() + self.assertIn(recipe, content) + # The commit between versions fixes a typo - verify we got real content + self.assertIn('typo', content) + # Check devtool reset cleans up changelog + runCmd('devtool reset %s -n' % recipe) + self.assertNotExists(changelog_file, 'Changelog file should be removed after reset')
Rather than write a whole new test (which adds to the overall testing time, copy-pastes code, and repeats the upgrade procedure already happening in a different test), I think the changelog checks should be added to existing tests in DevtoolUpgradeTests class. At least these tests:
- test_devtool_upgrade
- _test_devtool_upgrade_git_by_recipe
but ideally everything where upgrade operation runs and changelogs are extracted.
Also, don't look for simple strings as a way to check the changelog sanity. Instead, write a 'reference changelog' into meta-selftest, and compare that with the extracted changelog in the workspace, similar to how upgraded recipes are compared with reference data:
# Check recipe got changed as expected with open(oldrecipefile + '.upgraded', 'r') as f:
desiredlines = f.readlines()
with open(newrecipefile, 'r') as f:
newlines = f.readlines()
self.assertEqual(desiredlines, newlines)
Such a comparison could probably be in a helper function to avoid repeating code lines.
It's okay if some of the upgrades are unable to extract anything useful into the changelog, then the reference data should simply stay empty. If you can cover all of these, would be awesome:
meta-selftest/recipes-devtools/python/python3-guessing-game-crates.inc.upgraded meta-selftest/recipes-devtools/python/python3-guessing-game_git.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test1_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test2_git.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
Cheers,
Alex
RE: [OE-core] [PATCH 1/3] devtool: upgrade: extract changelog between versions
Quoted 22 lines
-----Original Message-----
From: Alexander Kanavin <[email protected]>
Sent: Tuesday, 12 May 2026 18:28
To: Daniel Turull <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH 1/3] devtool: upgrade: extract changelog between versionsQuoted 9 lines · Daniel Turull via lists.openembedded.org
Automatically extract changelog information when upgrading a recipe. Uses the devtool-base tags created during upgrade to diff known changelog files (NEWS, ChangeLog, CHANGES, etc.) between the old and new versions. For git-based sources, falls back to git log --oneline if no changelog file changed.
Output is written to workspace/changelogs/<pn>.txt and cleaned up on devtool reset. This allows AUH and other tools to pick up the changelog without implementing their own extraction logic.
Quoted 7 lines
Thanks, I like this a lot, and I think this should be fairly easy to get merged. Just a couple notes:
- probably patches 2/3 and 3/3 should all be folded into the main commit? (but also add those commit messages to the main commit message, don't discard the additional information)
Sure, I'll squash them into one.
Quoted 63 lines
- please see below this about testing the functionality
meta/lib/oeqa/selftest/cases/devtool.py class DevtoolUpgradeTests(DevtoolBase):
Quoted 3 lines
meta/lib/oeqa/selftest/cases/devtool.py +3
-0+ def test_devtool_upgrade_changelog(self): + # Check preconditions + self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot berun with a workspace directory under the build directory')
Review
Quoted 2 lines
(quoted diff) +2
-0+ self.track_for_cleanup(self.workspacedir) + self.add_command_to_tearDown('bitbake-layers remove-layer*/workspace')
Quoted 1 line
+ # dbus-wait has ChangeLog/NEWS files and one commit between these
revisions
meta/lib/oeqa/selftest/cases/devtool.py class DevtoolUpgradeTests(DevtoolBase):
Quoted 8 lines
meta/lib/oeqa/selftest/cases/devtool.py +8
-0+ recipe = 'devtool-upgrade-test2' + commit = '6cc6077a36fe2648a5f993fe7c16c9632f946517' + tempdir = tempfile.mkdtemp(prefix='devtoolqa') + self.track_for_cleanup(tempdir) + # Perform upgrade + runCmd('devtool upgrade %s %s -S %s' % (recipe, tempdir, commit)) + # Check changelog file was created with expected content + changelog_file = os.path.join(self.workspacedir, 'changelogs', '%s.txt' %recipe)
Quoted 1 line
+ self.assertExists(changelog_file, 'Changelog file should exist after
upgrade')
meta/lib/oeqa/selftest/cases/devtool.py class DevtoolUpgradeTests(DevtoolBase):
Quoted 9 lines
meta/lib/oeqa/selftest/cases/devtool.py +9
-0+ with open(changelog_file, 'r') as f: + content = f.read() + self.assertIn(recipe, content) + # The commit between versions fixes a typo - verify we got real content + self.assertIn('typo', content) + # Check devtool reset cleans up changelog + runCmd('devtool reset %s -n' % recipe) + self.assertNotExists(changelog_file, 'Changelog file should + be removed after reset')Rather than write a whole new test (which adds to the overall testing time, copy- pastes code, and repeats the upgrade procedure already happening in a different test), I think the changelog checks should be added to existing tests in DevtoolUpgradeTests class. At least these
tests:-
test_devtool_upgrade
-_test_devtool_upgrade_git_by_recipebut ideally everything where upgrade operation runs and changelogs are extracted.
Also, don't look for simple strings as a way to check the changelog sanity. Instead, write a 'reference changelog' into meta-selftest, and compare that with the extracted changelog in the workspace, similar to how upgraded recipes are compared with reference data:
# Check recipe got changed as expected with
open(oldrecipefile + '.upgraded', 'r')as f:
desiredlines =f.readlines()
withopen(newrecipefile, 'r')as f:
newlines =f.readlines()
self.assertEqual(desiredlines, newlines)Such a comparison could probably be in a helper function to avoid repeating code lines.
It's okay if some of the upgrades are unable to extract anything useful into the changelog, then the reference data should simply stay empty. If you can cover all of these, would be awesome:
Quoted 9 lines
meta-selftest/recipes-devtools/python/python3-guessing-game- crates.inc.upgraded meta-selftest/recipes-devtools/python/python3-guessing-game_git.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test1_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test2_git.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test3_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test4_1.5.3.bb.upgraded meta-selftest/recipes-test/devtool/devtool-upgrade-test5_git.bb.upgraded
I'll redo the tests with your suggestions and send a v2
Thanks
Daniel
Quoted 2 lines
Cheers,
Alex
PATCH 2/3 devtool: upgrade: detect per-version release notes files
In reply to [email protected]From: Daniel Turull <[email protected]>
Extend the changelog file detection loop to also match per-version release notes files like git's Documentation/RelNotes/2.53.0.adoc or mesa's docs/relnotes/26.0.3.rst.
These are detected by matching filenames that contain a version number with a documentation extension (.txt, .md, .rst, .adoc). Their full content is read via git show since they are new files rather than modifications to an existing changelog.
--- scripts/lib/devtool/upgrade.py | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/lib/devtool/upgrade.py +6 -0
@@ -576,6 +576,12 @@ def _extract_changelog(srctree, pn, old_ver, new_ver, old_tag, new_tag, workspac if lines: changelog_content = '\n'.join(lines) break + # Per-version release notes (e.g., git RelNotes/2.53.0.adoc, mesa relnotes/26.0.3.rst) + elif re.search(r'(\d+[.\-])+\d+\.(txt|md|rst|adoc)$', basename): + file_content, _ = _run('git show %s' % shlex.quote('%s:%s' % (new_tag, fname)), srctree) + if file_content.strip(): + changelog_content = file_content.strip() + break except bb.process.ExecutionError as e: logger.warning('Changelog file extraction failed: %s' % str(e))
Signature · 1 line
2.34.1
PATCH 3/3 devtool: upgrade: clean up extracted changelog content
In reply to [email protected]From: Daniel Turull <[email protected]>
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.
--- scripts/lib/devtool/upgrade.py | 5 +++++ 1 file changed, 5 insertions(+)
scripts/lib/devtool/upgrade.py +5 -0
@@ -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)
Signature · 1 line
2.34.1