Squash merge: "---------" separator before Co-authored-by pushes trailers in the PR description out of git's trailer block #214043
Replies: 5 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
Your analysis matches how git defines it. Per git-interpret-trailers, the trailer block is by definition at the end of the message, and the Workarounds until it is changed:
Since this is product behaviour, the discussion is the right place for the feedback; the GitHub bot above already catalogued it. |
|
Good catch—this is a classic Git trailer parsing quirk. Because Building on what @leonardo-tcarvalho already shared, here are two practical ways to handle this in your workflow right now while waiting for a native GitHub setting: 1. Automate it with a GitHub Action (Best for team-wide consistency)If you don't want developers manually editing the squash commit box every time, you can run a lightweight workflow triggered on Alternatively, if you use GitHub Actions to enforce commit conventions before merge, avoid relying on 2. Re-format trailers in your release/changelog toolingIf your release pipeline uses git log -1 --format=%B | sed '/^---------$/d' | git interpret-trailers --parse |
|
@mrt181 Your analysis lines up with git's docs: a trailer block is the group of lines at the very end of the message, and it has to be all trailers (or mostly trailers with at least one git-recognized one). Once GitHub adds "---------" and a new paragraph, Co-authored-by becomes the last block and Ref: is left behind. Appending the co-authors to an existing trailing block, as you suggest, looks like the cleanest fix. Upvoting. |
|
Your analysis is correct, and it's worth stating precisely why, because the mechanism is a bit more specific than "git only reads the last paragraph". What git actually does
GitHub's generated squash message is: The Note the divider itself is not special to git: a line only acts as a comment/divider when it starts with Workarounds that actually work today
Your suggestion (append |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Product Feedback
💬 Feature/Topic Area
Other
Body
What is happening
When a pull request is squash-merged with the default commit message "Pull request
title and description" and the PR has commits from more than one author, GitHub
appends the co-authors as a separate paragraph after a "---------" line:
git only reads the last paragraph of a message as its trailer block. Any trailer
written at the end of the PR description (here
Ref:, but alsoSigned-off-by:,Reviewed-by:,Fixes:etc.) is therefore no longer a trailer:Listing the co-author in the description directly under
Ref:does not help:GitHub appends its own block anyway and the co-author appears twice.
Steps to reproduce
title and description".
a trailer, e.g.
Ref:AB#123.gh pr merge --squash).git interpret-trailers --parseon the merge commit.Expected
The description's trailers and the co-authors end up in one trailer block, e.g.
Why it matters
Teams that squash-merge put work item references and other trailers in the PR
description because it becomes the commit message. Release tooling, changelog
generators and commit checks read them with git's trailer parsing
(
%(trailers),git interpret-trailers). As soon as a PR has a co-author, thosetrailers silently disappear from the history.
Suggestion
If the generated message already ends with a trailer block, append the
Co-authored-by lines to that block instead of adding "---------" and a new
paragraph. Alternatively, a repository setting to omit the separator.
see also:
https://github.com/orgs/community/discussions/212930#discussioncomment-19832689
https://github.com/orgs/community/discussions/212929#discussioncomment-19620956
All reactions