You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue or pull request for this?
I have searched the existing issues and pull requests
Feature description
We can match commits in commit_parsers like so:
commit_parsers = [
# Rewrite history
{ sha = "20246539df88431c72d65d7d0d1b82fba3deec34", group = "<!-- 0 -->Added" }, # Initial commit
]
However, this is a bit of a hassle since git cliff -vv dumps the short SHA e.g.,
TRACE git_cliff_core::process > process_commits: 2024653 - Grouping error: `Commit does not belong to any group` (Initial commit)
I had quite a few and while it wasn't too hard to get the full SHAs, it would be much easier if we could just block copy the short SHAs you already printed out.
Short SHAs (7+ chars) should be plenty for most repos, but people could always use more so any number of unambiguous chars should be supported, erring if there is any ambiguity just like git would.
Desired solution
Support any number of unambiguous short SHAs and err like git would when any ambiguity is hit.
Alternatives considered
Use a script or agent to resolve the short SHAs as needed, which is what I did but it would've been easier to just avoid needing to.
Well, I had one ready but needed to fix #1640 first and seems @yuefdev published first. I also saw in CONTRIBUTING.md it recommended discussion first. I only submitted the bug fix PR because it was a simple fix and I figured there'd be little discussion needed.
My change was simpler. It allowed for ambiguity as a simple check when I realized the flow was just doing a simple string match. Could be desirable as a simple !str.starts_with. But if you'd rather take @yuefdev's that does err on ambiguities that's fine, of course. I just worry how that will scale in a large monorepo with thousands of commits.
Thanks @heaths, sorry for the overlap! The ambiguity check in #1642 follows the original request to reject ambiguous prefixes, but your scaling concern is fair. It scans the collected commit IDs once per abbreviated SHA parser, before normal commit processing; I have not benchmarked it on a large monorepo. It also only checks commits included in the changelog, so it is not equivalent to repository-wide Git resolution.
Your prefix-match approach is simpler if matching multiple commits is acceptable. Happy to align with whichever behaviour you and @orhun prefer; no need to favour #1642 because it landed first.
It also only checks commits included in the changelog, so it is not equivalent to repository-wide Git resolution.
Good point. I noted that when I reviewed but forgot it while writing the comment.
Your prefix-match approach is simpler if matching multiple commits is acceptable.
I'm fine either way. Whatever @orhun prefers. A simple substring match (starts_with, not just anywhere) could be useful but may also—though mathematically improbable after a certain number of chars—inadvertently surprise people if another substring match occurs unexpectedly. As you noted, the perf impact is at least lessened since you're only resolving short SHAs authored into commit_parsers. My gut: yours is safest.
Activity
orhun commentedon Sep 13, 2026
Sounds good, PR welcome!
heaths commentedon Sep 14, 2026
Well, I had one ready but needed to fix #1640 first and seems @yuefdev published first. I also saw in
CONTRIBUTING.mdit recommended discussion first. I only submitted the bug fix PR because it was a simple fix and I figured there'd be little discussion needed.My change was simpler. It allowed for ambiguity as a simple check when I realized the flow was just doing a simple string match. Could be desirable as a simple
!str.starts_with. But if you'd rather take @yuefdev's that does err on ambiguities that's fine, of course. I just worry how that will scale in a large monorepo with thousands of commits.yuefdev commentedon Sep 14, 2026
Thanks @heaths, sorry for the overlap! The ambiguity check in #1642 follows the original request to reject ambiguous prefixes, but your scaling concern is fair. It scans the collected commit IDs once per abbreviated SHA parser, before normal commit processing; I have not benchmarked it on a large monorepo. It also only checks commits included in the changelog, so it is not equivalent to repository-wide Git resolution.
Your prefix-match approach is simpler if matching multiple commits is acceptable. Happy to align with whichever behaviour you and @orhun prefer; no need to favour #1642 because it landed first.
heaths commentedon Sep 14, 2026
Good point. I noted that when I reviewed but forgot it while writing the comment.
I'm fine either way. Whatever @orhun prefers. A simple substring match (
starts_with, not just anywhere) could be useful but may also—though mathematically improbable after a certain number of chars—inadvertently surprise people if another substring match occurs unexpectedly. As you noted, the perf impact is at least lessened since you're only resolving short SHAs authored intocommit_parsers. My gut: yours is safest.yuefdev commentedon Sep 30, 2026
Thanks for checking it over! Agreed on avoiding surprises from ambiguous prefixes. Happy to follow whichever behaviour @orhun prefers.
orhun commentedon Oct 31, 2026
I agree we should reject ambiguous prefixes to avoid surprising matches.
feat(parser): support abbreviated SHAs in commit parsers (orhun#1642)