Skip to content

Fix changelog generation for backport releases#501

Open
arnavk23 wants to merge 16 commits intoJuliaRegistries:masterfrom
arnavk23:fix-issue-181
Open

Fix changelog generation for backport releases#501
arnavk23 wants to merge 16 commits intoJuliaRegistries:masterfrom
arnavk23:fix-issue-181

Conversation

@arnavk23
Copy link
Collaborator

@arnavk23 arnavk23 commented Feb 13, 2026

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.x could include issues and PRs that were already released in v2.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:

  • PRs: from the SemVer predecessor's release date to the backport commit date, filtered to PRs merged into the release branch.
  • Issues: from the chronologically-latest prior release before the commit date to the commit date.

For normal (non-backport) releases the existing SemVer-based logic is unchanged.

Changes

File Change
tagbot/action/repo.py Add branches_of_commit(sha) — returns non-default remote branches containing the commit; is_backport_commit(sha) delegates to it
tagbot/action/changelog.py Add _previous_release_chronological — finds latest release before a given commit date (timezone-aware); add _pulls_on_branches — filters PRs by base branch; rewrite _collect_data backport path to use dual windows
test/action/test_repo.py Tests for branches_of_commit and is_backport_commit covering HEAD symrefs, failures, and multi-branch cases
test/action/test_changelog.py Tests for _previous_release_chronological, _pulls_on_branches, and the backport path of _collect_data

Bug fixes included

  • is_backport_commit previously used any(b != default) which returned True for commits on the default branch that also happened to appear on other branches. Replaced with an explicit exclude of the default branch.
  • git branch -r output includes origin/HEAD -> origin/main symbolic refs; these are now filtered out.
  • Naive/aware datetime comparison in _previous_release_chronological fixed by passing all release times through _ensure_utc().
  • Duplicate get_commit(sha) API call in _collect_data removed.

- 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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

arnavk23 and others added 5 commits February 14, 2026 01:25
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
arnavk23 and others added 5 commits February 18, 2026 21:56
- 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>
@IanButterworth
Copy link
Member

@arnavk23 This wasn't fully fixing #181, so again hope you don't mind, I added branch-filtered PR collection and a chronological issue window (and fixed a few logic bugs in the PR).

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More accurate release notes for backport releases

3 participants