Attribute a backported commit to the pull request it came from - #3054
Merged
Conversation
A backport is a cherry-pick, so the only pull request its commit is associated with is the one that carried the backport. That pull request says nothing about the change, and every commit it brought over resolves to it, so a release branch's changelog credits all of its entries to one number -- 4.0.3 lists three, all of them #3005. `git cherry-pick -x` records the commit a cherry-pick was made from, so follow it: look the recorded origin up instead of the commit, and the changelog names the pull request the change was written and reviewed in. A commit backported twice carries one line per hop, so the first one, where the change started, is the one used. An origin that leads nowhere -- a commit cherry-picked from a fork, or one that reached the default branch without a pull request -- falls back to the commit in this history, which is at least the backport that brought it here. Cherry-picks made without `-x` record nothing to follow and behave as before. The commit messages are read with `%B`, so the output is forced to UTF-8: unlike the SHAs read until now, a message can hold anything, and splitting one that is not ASCII fails under `LANG=C`, as in CI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvSmN7ats6HGEyeT7VEbau
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.
A backport is a cherry-pick, so its commit is only associated with the pull request that carried the backport — which says nothing about the change, and is the same number for every commit it brought over. All three entries in the 4.0.3 changelog cite #3005.
git cherry-pick -xrecords the commit a cherry-pick was made from, sogem:changelognow follows it and looks the origin up instead. An origin that leads nowhere falls back to the commit in this history, and cherry-picks made without-xbehave as before.That last part means this only does anything if backports use
-x, whichdocs/release.mdnow says.Generated by Claude Code