fix(commands/bump): prevent using incremental changelog when it is set to false in config
Fix #883
Description
Since the default behavior of cz bump --changelog is to write incremental changelog, which is different from the default value of changelog_incremental, it is hard to know the value is set from user or the default setting, To address it, I created one more member in BaseConfig to record which property is defined from users so that we could distinguish the value is from default setting or users.
Checklist
- [ ] Add test cases to all the changes you introduce
- [x] Run
./scripts/formatand./scripts/testlocally to ensure this change passes linter check and test - [x] Test the changes on the local machine manually
- [x] Update the documentation for the changes
Expected behavior
cz bump --changelog should work as false when user configure changelog_incremental to false.
Steps to Test This Pull Request
-
Modify the CHANGELOG file
-
Configure
pyproject.tomlwithchangelog_incremental = false -
Run
cz bump --changelog -
Check the CHANGELOG, which the new added content should be replaced
Additional context
ditto.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.45%. Comparing base (
120d514) to head (d439c38). Report is 231 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #996 +/- ##
==========================================
+ Coverage 97.33% 97.45% +0.11%
==========================================
Files 42 55 +13
Lines 2104 2398 +294
==========================================
+ Hits 2048 2337 +289
- Misses 56 61 +5
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 97.45% <100.00%> (+0.11%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Just opening the debate: wouldn't it be easier and more consistent to fix/align the default bump behavior to the default settings (even if this is a breaking change) ?
By adding a fourth settings source of trust (defaults, user settings, cli flags and now mutated settings, fifth if you add the fact that plugins can override some settings), I feel that we are fixing a symptom but making the problem more complex.
Just opening the debate: wouldn't it be easier and more consistent to fix/align the default
bumpbehavior to the default settings (even if this is a breaking change) ?By adding a fourth settings source of trust (defaults, user settings, cli flags and now mutated settings, fifth if you add the fact that plugins can override some settings), I feel that we are fixing a symptom but making the problem more complex.
Yeah, I think that would be a better way to address the issue if possible. The implementation would be easier and also could prevent overriding the behaviors from multiple sources when running the bump --changelog.
Just opening the debate: wouldn't it be easier and more consistent to fix/align the default bump behavior to the default settings (even if this is a breaking change) ?
Could you make a proposal for this? It sounds interesting, would be nice if we can simplify the settings
I'm a bit confused here. I thought we could solve it by reading the value from config?
I thought we could solve it by reading the value from config?
I think there are total three combinations of configurations here:
- user didn't specify
changelog_incremental, the Config would store the value asFalseand the value passing intoChangelogshould beTrue - user did specify
changelog_increamental: true, the Config would store the value asTrue, so the value passing intoChangelogwould also beTrue - user did specify
changelog_increamental: false, the Config would store the value asFalse, so the value passing intoChangelogwould also beFalse
The 1st & 3rd cases would cause ambiguity when we're reading the value from Config, we couldn't tell if the False value is set from the default value or user configuration, according to different source of the value we would take different value to pass into the initialization of Changelog. To address this, I introduce one more property that trace the value set from users to help us differentiate them in this PR.
we couldn't tell if the False value is set from the default value or user configuration,
I thought the one from the config should overwrite the default. Or did I miss anything?