Skip to content

fix: strip squash-merge "(#N)" suffix from release-note bullets - #11

Merged
fiunchinho merged 1 commit into
mainfrom
strip-squash-pr-suffix
Jun 3, 2026
Merged

fix: strip squash-merge "(#N)" suffix from release-note bullets#11
fiunchinho merged 1 commit into
mainfrom
strip-squash-pr-suffix

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Summary

v1.3.1's release notes ended up with a duplicate PR reference:

- Tighten release-notes whitespace in cliff template (#10) in [#10](https://...) by [@fiunchinho](...)
                                                       ^^^^^    ^^^^^

The first (#10) is auto-appended by GitHub to squash-merge commit messages; the second is the explicit link we render via cliff's GitHub integration. The first becomes redundant once we have the second.

Adds a commit_preprocessor that strips the trailing (#N) from each commit message before parsing.

Diff

 sort_commits = "oldest"

+commit_preprocessors = [
+  { pattern = '(?m) \(#\d+\)$', replace = "" },
+]
+
 commit_parsers = [

(+ documentation comment explaining the (?m) flag is load-bearing.)

Why (?m)?

git-cliff's regex defaults to single-line mode, so $ matches end-of-text. The squash (#N) lives at end-of-subject-line, with the commit body following. Without (?m), the pattern silently fails to match. With it, $ matches end-of-line and the trailing ref strips cleanly. Bodies' (#N) references are unaffected.

Verified locally

$ git-cliff --tag-pattern 'v*.*.*' v1.3.0..v1.3.1 --strip all
### Fixed

- Tighten release-notes whitespace in cliff template in [#10](https://...) by [@fiunchinho](...)

Test plan

  • Squash-merge this PR.
  • Confirm v1.3.2 release renders without (#11) appearing twice in the bullet.

The v1.3.1 release rendered as:
  "Tighten release-notes whitespace in cliff template (#10) in [#10](url) by [@fiunchinho]"
                                                       ^^^^^    ^^^^^
The first "(#10)" is auto-appended by GitHub to squash-merge commit
messages; the second is the explicit link we render via cliff's GitHub
integration. The first becomes redundant once we have the second.

Add a commit_preprocessor that strips the trailing "(#N)" before
parsing. The `(?m)` flag is load-bearing — git-cliff's regex defaults
to single-line mode, so `$` would only match end-of-text; the squash
`(#N)` lives at end-of-subject-line (with a body following), so we need
end-of-line semantics.

Verified locally that v1.3.1's bullet now renders cleanly without the
duplicate ref, and that "(#N)" references inside commit bodies are
left untouched.
@fiunchinho fiunchinho self-assigned this Jun 3, 2026
@fiunchinho
fiunchinho merged commit ddc2357 into main Jun 3, 2026
1 check passed
@fiunchinho
fiunchinho deleted the strip-squash-pr-suffix branch June 3, 2026 13:11
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.

1 participant