Context
The Lint workflow's pre-commit job turns red on main after every release, and then on every PR opened
afterwards, because the release commit regenerates docs/change-log.md with trailing whitespace that the
trailing-whitespace hook rewrites.
This has already happened once and was patched by hand: release: 0.47.0 (#894) made main red, and the
normalization rode along in #895. That fixed the symptom for the current file — it did not fix the generator, so
the next cz bump reintroduces it.
Problem / Current Behaviour
[tool.commitizen] sets update_changelog_on_bump = true with no custom changelog template, so cz bump
regenerates docs/change-log.md from commit bodies verbatim. Conventional-commit bodies in this repo are wrapped
by hand, and commitizen indents the wrapped continuation lines — emitting lines padded with 40-99 trailing
spaces.
The repo's trailing-whitespace hook is configured args: [--markdown-linebreak-ext=md], which preserves an
intentional two-space markdown line break but rewrites anything longer. So the hook reports "files were modified"
and pre-commit exits non-zero.
Measured on 6b435aa9 (release: 0.47.0):
lines ending in a space : 72
trailing-space widths : [2, 40, 41, 42, 47, 53, 62, 64, 86, 99]
versus the current, hand-normalized file:
lines ending in a space : 71
trailing-space widths : [2] # only genuine markdown line breaks
Two consequences beyond the red build:
Lint runs on pull_request, and actions/checkout builds the PR's merge commit, so every open PR
inherits main's broken changelog and goes red through no fault of its own.
- The fix is invisible to the contributor: the failure names
docs/change-log.md, a file their branch never
touched.
Affected locations
| File |
Symbol |
Notes |
pyproject.toml |
[tool.commitizen] (L244-249) |
update_changelog_on_bump = true, no template configured |
docs/change-log.md |
— |
the regenerated artefact |
.pre-commit-config.yaml |
trailing-whitespace (L13-15) |
--markdown-linebreak-ext=md; rewrites >2-space padding |
.github/workflows/lint.yml |
pre-commit job |
fails on main and on every PR's merge commit |
Steps to Reproduce
cz bump # or the release workflow
python -c "d=open('docs/change-log.md','rb').read(); \
print(sorted({len(l)-len(l.rstrip(b' ')) for l in d.split(b'\n') if l.endswith(b' ')}))"
# -> widths well above 2, e.g. [2, 40, 41, ...]
pre-commit run trailing-whitespace --files docs/change-log.md
# -> Failed: files were modified by this hook
Proposed Solution
Fix it at the generator rather than after each release. Options, roughly in order of preference:
- Strip the padding during generation — supply a commitizen changelog template (
template = "..." under
[tool.commitizen]) that emits unpadded bodies, or a changelog_message_builder_hook that rstrip()s each
line of the message body before it is rendered.
- Normalize as part of the bump — have the release workflow run
pre-commit run trailing-whitespace --files docs/change-log.md (or a plain sed -i 's/[[:space:]]*$//')
immediately after cz bump and include the result in the release commit.
- Exclude the generated file from the hook — add
exclude: ^docs/change-log\.md$ to the
trailing-whitespace hook. Cheapest, but it stops linting a file that is otherwise fine, and hides any future
whitespace problem in it.
Whichever is chosen, the check should be that a fresh cz bump leaves pre-commit run --all-files green with no
manual step.
Out of Scope
- Rewriting existing changelog history.
- Any other commitizen behaviour (version bumping, tagging, commit parsing).
Effort Estimate
Size: S (half-day)
Rationale: the change itself is small — a template, a hook, or a workflow step — but it needs a real bump to
verify, so the confirmation loop is the slow part.
Definition of Done
Related
Context
The
Lintworkflow'spre-commitjob turns red onmainafter every release, and then on every PR openedafterwards, because the release commit regenerates
docs/change-log.mdwith trailing whitespace that thetrailing-whitespacehook rewrites.This has already happened once and was patched by hand:
release: 0.47.0(#894) mademainred, and thenormalization rode along in #895. That fixed the symptom for the current file — it did not fix the generator, so
the next
cz bumpreintroduces it.Problem / Current Behaviour
[tool.commitizen]setsupdate_changelog_on_bump = truewith no custom changelog template, socz bumpregenerates
docs/change-log.mdfrom commit bodies verbatim. Conventional-commit bodies in this repo are wrappedby hand, and commitizen indents the wrapped continuation lines — emitting lines padded with 40-99 trailing
spaces.
The repo's
trailing-whitespacehook is configuredargs: [--markdown-linebreak-ext=md], which preserves anintentional two-space markdown line break but rewrites anything longer. So the hook reports "files were modified"
and
pre-commitexits non-zero.Measured on
6b435aa9(release: 0.47.0):versus the current, hand-normalized file:
Two consequences beyond the red build:
Lintruns onpull_request, andactions/checkoutbuilds the PR's merge commit, so every open PRinherits
main's broken changelog and goes red through no fault of its own.docs/change-log.md, a file their branch nevertouched.
Affected locations
pyproject.toml[tool.commitizen](L244-249)update_changelog_on_bump = true, no template configureddocs/change-log.md.pre-commit-config.yamltrailing-whitespace(L13-15)--markdown-linebreak-ext=md; rewrites >2-space padding.github/workflows/lint.ymlpre-commitjobmainand on every PR's merge commitSteps to Reproduce
Proposed Solution
Fix it at the generator rather than after each release. Options, roughly in order of preference:
template = "..."under[tool.commitizen]) that emits unpadded bodies, or achangelog_message_builder_hookthatrstrip()s eachline of the message body before it is rendered.
pre-commit run trailing-whitespace --files docs/change-log.md(or a plainsed -i 's/[[:space:]]*$//')immediately after
cz bumpand include the result in the release commit.exclude: ^docs/change-log\.md$to thetrailing-whitespacehook. Cheapest, but it stops linting a file that is otherwise fine, and hides any futurewhitespace problem in it.
Whichever is chosen, the check should be that a fresh
cz bumpleavespre-commit run --all-filesgreen with nomanual step.
Out of Scope
Effort Estimate
Size:
S(half-day)Rationale: the change itself is small — a template, a hook, or a workflow step — but it needs a real bump to
verify, so the confirmation loop is the slow part.
Definition of Done
cz bumpproduces adocs/change-log.mdwith no trailing whitespace beyond intentional two-spacemarkdown line breaks.
pre-commit run --all-filesis green immediately after a bump, with no manual normalization.mainand newly opened PRs stay green through a release.Related
release: 0.47.0, the bump that introduced the padding