fix(changelog): allow --no-incremental to override changelog_incremental config - #2086
bearomorphism wants to merge 4 commits into
Conversation
🔍 Commitizen bump previewMerging this PR will produce the following bump: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2086 +/- ##
=======================================
Coverage 98.26% 98.26%
=======================================
Files 61 61
Lines 2829 2830 +1
=======================================
+ Hits 2780 2781 +1
Misses 49 49 ☔ View full report in Codecov by Harness. |
|
Pushed the |
|
Interesting... I didn't know --no-XXX works |
There was a problem hiding this comment.
🟡 Changes recommended
Add the requested regression test and refresh the stale changelog help artifact.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds --no-incremental support so CLI arguments override changelog_incremental configuration, fixing release-note generation.
Changes:
- Updates changelog flag precedence and release workflow usage.
- Documents the override and refreshes Python-version help fixtures.
File summaries
| File | Summary |
|---|---|
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_changelog_.txt |
Updated changelog help fixture. |
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_changelog_.txt |
Updated changelog help fixture. |
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_changelog_.txt |
Updated changelog help fixture. |
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_changelog_.txt |
Updated changelog help fixture. |
tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_changelog_.txt |
Updated changelog help fixture. |
docs/commands/changelog.md |
Documents the incremental override. |
commitizen/commands/changelog.py |
Applies CLI-over-config precedence. Moderate (3 votes): add a regression test for --no-incremental with configured incremental mode and a revision range. Nit (1 vote): clarify the comment to mention the required flag. |
commitizen/cli.py |
Adds the boolean optional incremental flag. Nit (1 vote): regenerate the checked-in changelog help SVG. |
.github/workflows/bumpversion.yml |
Uses --no-incremental when generating release notes. |
Review details
Suppressed comments (2)
commitizen/cli.py:417
- This changes the rendered changelog help, but the checked-in
docs/images/cli_help/cz_changelog___help.svgstill shows only--incrementaland the old description. Becausedocs/commands/changelog.mdembeds that artifact and the regeneration workflow runs only onmaster, the documentation shipped with this change is stale; regenerate and include the SVG update.
"action": argparse.BooleanOptionalAction,
"default": None,
commitizen/commands/changelog.py:85
- This comment describes a bare
cz changelog <rev_range>as opting out, but with no CLI flagincremental_argisNoneand the following expression still falls back to the configured value. Underchangelog_incremental = true, that bare invocation still raises; mention the required--no-incrementalflag in the example.
# argument is `None` and we fall back to the config value. This lets a
# one-off invocation (e.g. `cz changelog <rev_range>`) opt out of an
# incremental default enabled in the configuration.
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
I don't understand, why do we need the https://github.com/commitizen-tools/setup-cz/blob/main/examples/bump-release.yaml#L44-L49 Can you rebase? I think there are already a bunch of things in |
…tal config
The "Bump version" workflow's release-notes step runs
`cz changelog --dry-run "${NEW_VERSION}"`, passing the new version as a
positional rev_range. Since pyproject.toml sets `changelog_incremental = true`
(#2074), this combination now always raises
"--incremental cannot be combined with a rev_range", failing every release.
There was previously no way to override a config-enabled
`changelog_incremental` back to false from the CLI, since `--incremental` was
a plain store_true flag defaulting to False.
- Change `--incremental` to use argparse.BooleanOptionalAction (default None),
adding a `--no-incremental` flag.
- CLI flag now takes precedence over the `changelog_incremental` config
setting; falls back to config only when neither flag is passed.
Note: `.github/workflows/bumpversion.yml` still needs to be updated to pass
`--no-incremental` in its release-notes step, but that change requires the
`workflow` OAuth scope and is left for a follow-up/maintainer to apply.
`cz bump`'s internal changelog call already hardcodes incremental=True, so it
is unaffected by this change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Complements the previous commit: now that the changelog command respects an explicit --no-incremental override, update the release workflow's one-off dry-run step to use it, fixing the actual pipeline failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the CLI help golden files (all supported Python versions) and docs/commands/changelog.md to reflect the new --no-incremental option added in a previous commit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… feedback - Add test_changelog_no_incremental_overrides_config_with_revision covering --no-incremental combined with a rev_range when changelog_incremental=true is set in config. - Clarify the comment in Changelog.__init__ to explicitly reference the --no-incremental flag needed to opt out. - Regenerate the stale docs/images/cli_help/cz_changelog___help.svg screenshot to include the new --no-incremental option. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
92614d5 to
3b41e05
Compare
|
hmm I have to go through the RCA again |
|
@woile Rebased onto current |
|
I think there should be a better solution. Sorry I should config my agent's instruction to prevent it from making noisy comments. |
|
new PR is #2088 closing this one |
Description
The "Bump version" workflow run failed while building GitHub release notes:
Root cause
This is not a general
--dry-runfailure. It requires the interaction of two repository-specific behaviors:ci: restore changelog updates #2074 enabled both
update_changelog_on_bump = trueandchangelog_incremental = true. Incremental generation is intentional forcz bump: it updates only the new section while preserving manually edited changelog history.After the bump,
.github/workflows/bumpversion.ymlseparately generates notes for the new GitHub Release with:cz changelog --dry-run "${NEW_VERSION}"The positional
${NEW_VERSION}is parsed asrev_range. The changelog command also inheritedchangelog_incremental = truefrom this repository's configuration, and Commitizen explicitly rejects combining incremental generation with a revision range.The setup-cz example uses the same
--dry-run <version>pattern, but it remains valid unless the consuming project also enableschangelog_incremental.--dry-runitself only prints instead of writing the changelog; it neither enables incremental mode nor creates the conflict.The CLI could enable incremental mode explicitly, but it could not disable a config-enabled value.
--incrementalusedstore_truewith aFalsedefault, while the command resolved it as:Therefore an omitted flag and an explicit false value were indistinguishable, and a configured
Truealways won.Fix
argparse.BooleanOptionalActionfor--incremental, adding the paired--no-incrementaloption and usingNonewhen neither form is supplied.changelog_incremental; fall back to configuration only when neither CLI form is supplied.--no-incremental, because it requests one exact release by revision whilecz bumpshould continue using incremental generation.--no-incrementalwithchangelog_incremental = trueand a revision range.This preserves the behavior introduced by #2074 for the repository changelog while allowing the separate release-note step to select its required non-incremental mode.
Alternatives considered
changelog_incremental = truewould make the release-note command work again, but would undo ci: restore changelog updates #2074's protection of manually edited changelog history duringcz bump.gh release create.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot following the guidelines
Code Changes
master.Steps to Test
changelog_incremental = true, runcz changelog --dry-run 4.18.1; it retains the existing conflict because no override was requested.cz changelog --no-incremental --dry-run 4.18.1; it generates that release without reading incremental mode from configuration.uv run pytest -q tests/commands/test_changelog_command.py tests/commands/test_common_command.py tests/test_cli.py.