Fix changelog generation for backport releases#501
Open
arnavk23 wants to merge 16 commits intoJuliaRegistries:masterfrom
Open
Fix changelog generation for backport releases#501arnavk23 wants to merge 16 commits intoJuliaRegistries:masterfrom
arnavk23 wants to merge 16 commits intoJuliaRegistries:masterfrom
Conversation
- Detect backport commits by checking if commit is on non-default branch - Use chronological previous release for backports instead of SemVer previous - This ensures backport changelogs only include relevant issues/PRs since the last release - Add _previous_release_chronological method for finding latest release before commit date - Add is_backport_commit method in Repo class
- E203: whitespace before ':' (conflicts with black's type hint formatting) - W503: line break before binary operator (conflicts with black's operator formatting) - This resolves CI failures due to black/flake8 style conflicts
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances changelog generation for backport releases by detecting commits on non-default branches and using chronological ordering (instead of semantic versioning) to determine the previous release. This ensures backport changelogs only include relevant issues/PRs since the last chronological release rather than the last semver release.
Changes:
- Added commit-level backport detection based on branch presence
- Added chronological release lookup for determining previous releases in time order
- Modified changelog generation to use appropriate previous release strategy based on commit type
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tagbot/action/repo.py | Adds is_backport_commit method to detect if a commit exists on non-default branches via git branch inspection |
| tagbot/action/changelog.py | Adds _previous_release_chronological method and integrates backport detection to select appropriate changelog strategy |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add test_is_backport_commit() covering branch detection logic - Add test_previous_release_chronological() covering chronological release finding - Tests cover edge cases: missing GitHub releases, prerelease versions, date ordering - Ensures backport changelog generation is thoroughly tested
- Shorten debug message in is_backport_commit to comply with 88 char limit
- Change logic to return True if commit is on ANY non-default branch - Previously incorrectly returned False for commits on both default and release branches - Now correctly identifies backports even when commit exists on multiple branches
- Test was raising generic Exception instead of Abort - Abort is the specific exception raised by git command failures - Ensures test correctly verifies exception handling in is_backport_commit
- Filter out 'origin/HEAD -> ...' symbolic ref lines from git branch -r output to prevent false-positive backport detection on default branch commits - Wrap rel_time values with _ensure_utc() in _previous_release_chronological to fix TypeError when comparing naive (time_of_commit) and aware datetimes - Apply _ensure_utc() to commit_date before passing to chronological lookup - Remove redundant get_commit() API call in _collect_data (reuse existing commit variable) - Revert unrelated setup.cfg flake8 ignore change - Fix fragile test side_effect iterator state in test_previous_release_chronological - Add test case for HEAD symbolic ref line filtering Co-authored-by: Claude <claude@anthropic.com>
- Add Repo.branches_of_commit(sha) which returns short names of all non-default remote branches containing the commit (filters HEAD symbolic refs and the default branch) - Repo.is_backport_commit now delegates to branches_of_commit For backport releases _collect_data now uses separate windows for issues and PRs: - PRs: filtered to those merged into the release branch(es) via the new Changelog._pulls_on_branches method, windowed from the SemVer predecessor (captures cherry-picks predating the last main release) - Issues: all closed since the chronological predecessor (no base-branch signal available for issues) - compare_url / previous_release still reference the SemVer predecessor Add tests: test_branches_of_commit, test_pulls_on_branches, test_collect_data_backport. Co-authored-by: Claude <claude@anthropic.com>
Member
The initial side_effect setup in test_previous_release_chronological was immediately overridden on the next line, making it dead code. Also remove the now-unused top-level import of UnknownObjectException (it is still imported locally inside a fixture where it is needed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated by @IanButterworth (and claude):
Summary
Fixes #181 — backport releases were getting incorrect changelogs because the previous-release lookup always used SemVer ordering, so a backport to
v1.xcould include issues and PRs that were already released inv2.x.Approach
A commit is a backport if it lives on a non-default branch (checked via
git branch -r --contains <sha>). For those releases we now use two separate windows:For normal (non-backport) releases the existing SemVer-based logic is unchanged.
Changes
tagbot/action/repo.pybranches_of_commit(sha)— returns non-default remote branches containing the commit;is_backport_commit(sha)delegates to ittagbot/action/changelog.py_previous_release_chronological— finds latest release before a given commit date (timezone-aware); add_pulls_on_branches— filters PRs by base branch; rewrite_collect_databackport path to use dual windowstest/action/test_repo.pybranches_of_commitandis_backport_commitcovering HEAD symrefs, failures, and multi-branch casestest/action/test_changelog.py_previous_release_chronological,_pulls_on_branches, and the backport path of_collect_dataBug fixes included
is_backport_commitpreviously usedany(b != default)which returnedTruefor commits on the default branch that also happened to appear on other branches. Replaced with an explicit exclude of the default branch.git branch -routput includesorigin/HEAD -> origin/mainsymbolic refs; these are now filtered out.datetimecomparison in_previous_release_chronologicalfixed by passing all release times through_ensure_utc().get_commit(sha)API call in_collect_dataremoved.