Skip to content

fix(commands/bump): prevent using incremental changelog when it is set to false in config#996

Draft
josix wants to merge 5 commits intocommitizen-tools:masterfrom
josix:fix/changelog-default-changelog-incremental
Draft

fix(commands/bump): prevent using incremental changelog when it is set to false in config#996
josix wants to merge 5 commits intocommitizen-tools:masterfrom
josix:fix/changelog-default-changelog-incremental

Conversation

@josix
Copy link
Contributor

@josix josix commented Feb 29, 2024

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
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • 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

  1. Modify the CHANGELOG file
    image

  2. Configure pyproject.toml with changelog_incremental = false

  3. Run cz bump --changelog

  4. Check the CHANGELOG, which the new added content should be replaced
    image

Additional context

ditto.

@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from 661a140 to d4894e5 Compare February 29, 2024 18:01
@codecov
Copy link

codecov bot commented Feb 29, 2024

❌ 20 Tests Failed:

Tests completed Failed Passed Skipped
1209 20 1189 4
View the top 3 failed test(s) by shortest run time
tests/commands/test_bump_command.py::test_changelog_merge_preserves_header[without_prerelease]
Stack Traces | 0.069s run time
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fb69fc09cc0>
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7fb69fc09cc0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7fb69f9ac7c0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7fb69fb0b8e0>)
changelog_path = PosixPath('CHANGELOG.md')
config_path = PosixPath('pyproject.toml')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7fb69f998050>
prerelease = False, merge = 'true'

    @pytest.mark.parametrize(
        ("prerelease", "merge"),
        [
            pytest.param(True, "true", id="with_prerelease_merge"),
            pytest.param(True, "false", id="with_prerelease_no_merge"),
            pytest.param(False, "true", id="without_prerelease"),
        ],
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2025-01-01")
    def test_changelog_merge_preserves_header(
        mocker: MockFixture,
        util: UtilFixture,
        changelog_path: Path,
        config_path: Path,
        file_regression: FileRegressionFixture,
        prerelease: bool,
        merge: str,
    ):
        """Test that merge_prerelease preserves existing changelog header."""
        with config_path.open("a") as f:
            f.write(f"changelog_merge_prerelease = {merge}\n")
            f.write("update_changelog_on_bump = true\n")
            f.write("annotated_tag = true\n")
    
        # Create initial version with changelog that has a header
        util.create_file_and_commit("irrelevant commit")
        mocker.patch("commitizen.git.GitTag.date", "1970-01-01")
        git.tag("0.1.0")
    
        # Create a changelog with a header manually
        changelog_path.write_text(
            dedent("""\
                # Changelog
    
                All notable changes to this project will be documented here.
    
                ## 0.1.0 (1970-01-01)
                """)
        )
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        if prerelease:
            util.run_cli("bump", "--prerelease", "alpha", "--yes")
    
        util.create_file_and_commit("feat: new feature right before the bump")
        util.run_cli("bump", "--changelog")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw0/test_changelog_merge_preserves2/test_changelog_merge_preserves_header_without_prerelease_.md
E       .../popen-gw0/test_changelog_merge_preserves2/test_changelog_merge_preserves_header_without_prerelease_.obtained.md
E       HTML DIFF: .../popen-gw0/test_changelog_merge_preserves2/test_changelog_merge_preserves_header_without_prerelease_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,7 +1,3 @@
E       -# Changelog
E       -
E       -All notable changes to this project will be documented here.
E       -
E        ## 0.2.0 (2025-01-01)
E        
E        ### Feat

.../tests/commands/test_bump_command.py:1550: AssertionError
tests/commands/test_bump_command.py::test_bump_changelog_contains_increment_only
Stack Traces | 0.093s run time
tmp_commitizen_project = local('.../pytest-0/popen-gw0/test_bump_changelog_contains_i0')
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7fb69f720870>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7fb69f88de10>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7fb69fb086e0>)
capsys = <_pytest.capture.CaptureFixture object at 0x7fb6a43be7a0>

    def test_bump_changelog_contains_increment_only(
        tmp_commitizen_project: Path, util: UtilFixture, capsys: pytest.CaptureFixture
    ):
        """Issue 1024"""
        # Initialize commitizen up to v1.0.0
        project_root = Path(tmp_commitizen_project)
        tmp_commitizen_cfg_file = project_root / "pyproject.toml"
        tmp_commitizen_cfg_file.write_text(
            '[tool.commitizen]\nversion="1.0.0"\nupdate_changelog_on_bump = true\n'
        )
        tmp_changelog_file = project_root / "CHANGELOG.md"
        tmp_changelog_file.write_text("## v1.0.0")
        util.create_file_and_commit("feat(user): new file")
        util.create_tag("v1.0.0")
    
        # Add a commit and bump to v2.0.0
        util.create_file_and_commit("feat(user)!: new file")
        util.run_cli("bump", "--yes")
        _ = capsys.readouterr()
    
        # Add a commit and create the incremental changelog to v3.0.0
        # it should only include v3 changes
        util.create_file_and_commit("feat(next)!: next version")
        with pytest.raises(ExpectedExit):
            util.run_cli("bump", "--yes", "--version-files-only", "--changelog-to-stdout")
        out, _ = capsys.readouterr()
    
        assert "3.0.0" in out
>       assert "2.0.0" not in out
E       AssertionError: assert '2.0.0' not in '## 3.0.0 (2...new file\n\n'
E         
E         '2.0.0' is contained here:
E           rsion
E           
E           ## 2.0.0 (2026-02-07)
E         ?    +++++
E           
E           ### Feat
E           
E           - **user**: new file
E           
E           ## v1.0.0 (2026-02-07)
E           
E           ### Feat
E           
E           - **user**: new file

.../tests/commands/test_bump_command.py:1211: AssertionError
tests/commands/test_bump_command.py::test_changelog_merge_preserves_header[with_prerelease_merge]
Stack Traces | 0.099s run time
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fb69fcc6ea0>
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7fb69fcc6ea0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7fb69f7afd90>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7fb6a483c730>)
changelog_path = PosixPath('CHANGELOG.md')
config_path = PosixPath('pyproject.toml')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7fb6a44079b0>
prerelease = True, merge = 'true'

    @pytest.mark.parametrize(
        ("prerelease", "merge"),
        [
            pytest.param(True, "true", id="with_prerelease_merge"),
            pytest.param(True, "false", id="with_prerelease_no_merge"),
            pytest.param(False, "true", id="without_prerelease"),
        ],
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2025-01-01")
    def test_changelog_merge_preserves_header(
        mocker: MockFixture,
        util: UtilFixture,
        changelog_path: Path,
        config_path: Path,
        file_regression: FileRegressionFixture,
        prerelease: bool,
        merge: str,
    ):
        """Test that merge_prerelease preserves existing changelog header."""
        with config_path.open("a") as f:
            f.write(f"changelog_merge_prerelease = {merge}\n")
            f.write("update_changelog_on_bump = true\n")
            f.write("annotated_tag = true\n")
    
        # Create initial version with changelog that has a header
        util.create_file_and_commit("irrelevant commit")
        mocker.patch("commitizen.git.GitTag.date", "1970-01-01")
        git.tag("0.1.0")
    
        # Create a changelog with a header manually
        changelog_path.write_text(
            dedent("""\
                # Changelog
    
                All notable changes to this project will be documented here.
    
                ## 0.1.0 (1970-01-01)
                """)
        )
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        if prerelease:
            util.run_cli("bump", "--prerelease", "alpha", "--yes")
    
        util.create_file_and_commit("feat: new feature right before the bump")
        util.run_cli("bump", "--changelog")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw0/test_changelog_merge_preserves0/test_changelog_merge_preserves_header_with_prerelease_merge_.md
E       .../popen-gw0/test_changelog_merge_preserves0/test_changelog_merge_preserves_header_with_prerelease_merge_.obtained.md
E       HTML DIFF: .../popen-gw0/test_changelog_merge_preserves0/test_changelog_merge_preserves_header_with_prerelease_merge_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,7 +1,3 @@
E       -# Changelog
E       -
E       -All notable changes to this project will be documented here.
E       -
E        ## 0.2.0 (2025-01-01)
E        
E        ### Feat

.../tests/commands/test_bump_command.py:1550: AssertionError
tests/commands/test_bump_command.py::test_changelog_merge_preserves_header[with_prerelease_no_merge]
Stack Traces | 0.1s run time
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fb69fcc53d0>
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7fb69fcc53d0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7fb69f9aef20>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7fb69f8d93b0>)
changelog_path = PosixPath('CHANGELOG.md')
config_path = PosixPath('pyproject.toml')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7fb6a4407680>
prerelease = True, merge = 'false'

    @pytest.mark.parametrize(
        ("prerelease", "merge"),
        [
            pytest.param(True, "true", id="with_prerelease_merge"),
            pytest.param(True, "false", id="with_prerelease_no_merge"),
            pytest.param(False, "true", id="without_prerelease"),
        ],
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2025-01-01")
    def test_changelog_merge_preserves_header(
        mocker: MockFixture,
        util: UtilFixture,
        changelog_path: Path,
        config_path: Path,
        file_regression: FileRegressionFixture,
        prerelease: bool,
        merge: str,
    ):
        """Test that merge_prerelease preserves existing changelog header."""
        with config_path.open("a") as f:
            f.write(f"changelog_merge_prerelease = {merge}\n")
            f.write("update_changelog_on_bump = true\n")
            f.write("annotated_tag = true\n")
    
        # Create initial version with changelog that has a header
        util.create_file_and_commit("irrelevant commit")
        mocker.patch("commitizen.git.GitTag.date", "1970-01-01")
        git.tag("0.1.0")
    
        # Create a changelog with a header manually
        changelog_path.write_text(
            dedent("""\
                # Changelog
    
                All notable changes to this project will be documented here.
    
                ## 0.1.0 (1970-01-01)
                """)
        )
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        if prerelease:
            util.run_cli("bump", "--prerelease", "alpha", "--yes")
    
        util.create_file_and_commit("feat: new feature right before the bump")
        util.run_cli("bump", "--changelog")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw0/test_changelog_merge_preserves1/test_changelog_merge_preserves_header_with_prerelease_no_merge_.md
E       .../popen-gw0/test_changelog_merge_preserves1/test_changelog_merge_preserves_header_with_prerelease_no_merge_.obtained.md
E       HTML DIFF: .../popen-gw0/test_changelog_merge_preserves1/test_changelog_merge_preserves_header_with_prerelease_no_merge_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,14 +1,10 @@
E       -# Changelog
E       -
E       -All notable changes to this project will be documented here.
E       -
E        ## 0.2.0 (2025-01-01)
E        
E        ### Feat
E        
E        - new feature right before the bump
E        
E       -## 0.2.0a0 (2025-01-01)
E       +## 0.2.0a0 (1970-01-01)
E        
E        ### Feat

.../tests/commands/test_bump_command.py:1550: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[rc-alpha]
Stack Traces | 0.113s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba0280de0>
from_pre = 'rc', to_pre = 'alpha'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0689980>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba02818d0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0262120>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit10/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_alpha_.md
E       .../popen-gw2/test_changelog_incremental_wit10/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_alpha_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit10/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_alpha_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0rc1 (2021-06-11)
E       -
E        ## 0.2.0rc0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[rc-beta]
Stack Traces | 0.118s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba0283a10>
from_pre = 'rc', to_pre = 'beta'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba068bee0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba0282eb0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0263070>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit11/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_beta_.md
E       .../popen-gw2/test_changelog_incremental_wit11/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_beta_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit11/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_beta_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0rc1 (2021-06-11)
E       -
E        ## 0.2.0rc0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[rc-rc]
Stack Traces | 0.118s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba0283ee0>
from_pre = 'rc', to_pre = 'rc'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0a932b0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba0283f50>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0260d70>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit12/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_rc_.md
E       .../popen-gw2/test_changelog_incremental_wit12/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_rc_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit12/test_changelog_incremental_with_prerelease_version_to_prerelease_version_rc_rc_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0rc1 (2021-06-11)
E       -
E        ## 0.2.0rc0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_merge_prerelease[beta]
Stack Traces | 0.119s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8b9bf63f50>
test_input = 'beta'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0279300>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8b9bf63af0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0216d50>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2023-04-16")
    def test_changelog_incremental_with_merge_prerelease(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0")
    
        util.create_file_and_commit("feat: add new output")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes", "--changelog")
    
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--merge-prerelease", "--incremental")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit15/test_changelog_incremental_with_merge_prerelease_beta_.md
E       .../popen-gw2/test_changelog_incremental_wit15/test_changelog_incremental_with_merge_prerelease_beta_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit15/test_changelog_incremental_with_merge_prerelease_beta_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -21,17 +15,4 @@
E        
E        - add new output
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2023-04-16)

.../tests/commands/test_changelog_command.py:788: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_merge_prerelease[alpha]
Stack Traces | 0.124s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8b9bf601a0>
test_input = 'alpha'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba027add0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8b9bf618d0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0216710>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2023-04-16")
    def test_changelog_incremental_with_merge_prerelease(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0")
    
        util.create_file_and_commit("feat: add new output")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes", "--changelog")
    
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--merge-prerelease", "--incremental")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit14/test_changelog_incremental_with_merge_prerelease_alpha_.md
E       .../popen-gw2/test_changelog_incremental_wit14/test_changelog_incremental_with_merge_prerelease_alpha_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit14/test_changelog_incremental_with_merge_prerelease_alpha_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -21,17 +15,4 @@
E        
E        - add new output
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2023-04-16)

.../tests/commands/test_changelog_command.py:788: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_merge_prerelease[rc]
Stack Traces | 0.129s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba0211e80>
test_input = 'rc'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba02781f0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba0211a90>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba0263f70>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2023-04-16")
    def test_changelog_incremental_with_merge_prerelease(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0")
    
        util.create_file_and_commit("feat: add new output")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes", "--changelog")
    
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--merge-prerelease", "--incremental")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit13/test_changelog_incremental_with_merge_prerelease_rc_.md
E       .../popen-gw2/test_changelog_incremental_wit13/test_changelog_incremental_with_merge_prerelease_rc_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit13/test_changelog_incremental_with_merge_prerelease_rc_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -21,17 +15,4 @@
E        
E        - add new output
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2023-04-16)

.../tests/commands/test_changelog_command.py:788: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[beta-rc]
Stack Traces | 0.137s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba01eba10>
from_pre = 'beta', to_pre = 'rc'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba068be10>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba01eb7e0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba04eb2a0>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit9/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_rc_.md
E       .../popen-gw2/test_changelog_incremental_wit9/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_rc_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit9/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_rc_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0rc0 (2021-06-11)
E       -
E        ## 0.2.0b0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_release_candidate_version[beta]
Stack Traces | 0.138s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba051e430>
test_input = 'beta'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba06f5d90>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba051ec80>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba07af2a0>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_release_candidate_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w", encoding="utf-8") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--incremental")
    
        with changelog_path.open(encoding="utf-8") as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit3/test_changelog_incremental_with_release_candidate_version_beta_.md
E       .../popen-gw2/test_changelog_incremental_wit3/test_changelog_incremental_with_release_candidate_version_beta_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit3/test_changelog_incremental_with_release_candidate_version_beta_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -24,17 +18,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:691: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[beta-beta]
Stack Traces | 0.14s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba01ea7b0>
from_pre = 'beta', to_pre = 'beta'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0689b20>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba01eb150>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba04ebf70>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit8/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_beta_.md
E       .../popen-gw2/test_changelog_incremental_wit8/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_beta_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit8/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_beta_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0b1 (2021-06-11)
E       -
E        ## 0.2.0b0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[alpha-alpha]
Stack Traces | 0.141s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba054cfa0>
from_pre = 'alpha', to_pre = 'alpha'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0b31cc0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba054d8d0>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba04e8c30>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit4/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_alpha_.md
E       .../popen-gw2/test_changelog_incremental_wit4/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_alpha_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit4/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_alpha_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0a1 (2021-06-11)
E       -
E        ## 0.2.0a0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[alpha-beta]
Stack Traces | 0.142s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba054f5b0>
from_pre = 'alpha', to_pre = 'beta'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0bb4c80>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba054f230>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba04e90e0>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit5/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_beta_.md
E       .../popen-gw2/test_changelog_incremental_wit5/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_beta_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit5/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_beta_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0b0 (2021-06-11)
E       -
E        ## 0.2.0a0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[beta-alpha]
Stack Traces | 0.147s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba01e8d70>
from_pre = 'beta', to_pre = 'alpha'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba068af70>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba01e9a20>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba047b520>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit7/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_alpha_.md
E       .../popen-gw2/test_changelog_incremental_wit7/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_alpha_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit7/test_changelog_incremental_with_prerelease_version_to_prerelease_version_beta_alpha_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0b1 (2021-06-11)
E       -
E        ## 0.2.0b0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_prerelease_version_to_prerelease_version[alpha-rc]
Stack Traces | 0.151s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba054eeb0>
from_pre = 'alpha', to_pre = 'rc'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0bb7520>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba01e8050>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba04ea940>)

    @pytest.mark.parametrize(
        ("from_pre", "to_pre"), itertools.product(["alpha", "beta", "rc"], repeat=2)
    )
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_prerelease_version_to_prerelease_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        from_pre: str,
        to_pre: str,
        util: UtilFixture,
    ):
        with changelog_path.open("w") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", from_pre, "--yes")
    
        util.run_cli("bump", "--changelog", "--prerelease", to_pre, "--yes")
    
        with changelog_path.open() as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit6/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_rc_.md
E       .../popen-gw2/test_changelog_incremental_wit6/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_rc_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit6/test_changelog_incremental_with_prerelease_version_to_prerelease_version_alpha_rc_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,11 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E       -## 0.2.0rc0 (2021-06-11)
E       -
E        ## 0.2.0a0 (2021-06-11)
E        
E        ### Feat
E       @@ -16,17 +8,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:721: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_release_candidate_version[alpha]
Stack Traces | 0.153s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba051e3c0>
test_input = 'alpha'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0c4dcc0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba051e510>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba23fcb40>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_release_candidate_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w", encoding="utf-8") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--incremental")
    
        with changelog_path.open(encoding="utf-8") as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit2/test_changelog_incremental_with_release_candidate_version_alpha_.md
E       .../popen-gw2/test_changelog_incremental_wit2/test_changelog_incremental_with_release_candidate_version_alpha_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit2/test_changelog_incremental_with_release_candidate_version_alpha_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -24,17 +18,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:691: AssertionError
tests/commands/test_changelog_command.py::test_changelog_incremental_with_release_candidate_version[rc]
Stack Traces | 0.166s run time
changelog_path = PosixPath('CHANGELOG.md')
file_regression = <pytest_regressions.file_regression.FileRegressionFixture object at 0x7f8ba03ba510>
test_input = 'rc'
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8ba0b92820>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8ba03bbb60>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8ba248e530>)

    @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"])
    @pytest.mark.usefixtures("tmp_commitizen_project")
    @pytest.mark.freeze_time("2021-06-11")
    def test_changelog_incremental_with_release_candidate_version(
        changelog_path: Path,
        file_regression: FileRegressionFixture,
        test_input: str,
        util: UtilFixture,
    ):
        """Fix #357"""
        with changelog_path.open("w", encoding="utf-8") as f:
            f.write(KEEP_A_CHANGELOG)
        util.create_file_and_commit("irrelevant commit")
        util.create_tag("1.0.0", annotated=True)
    
        util.create_file_and_commit("feat: add new output")
        util.create_file_and_commit("fix: output glitch")
    
        util.run_cli("bump", "--changelog", "--prerelease", test_input, "--yes")
    
        util.create_file_and_commit("fix: mama gotta work")
        util.create_file_and_commit("feat: add more stuff")
        util.create_file_and_commit("Merge into master")
    
        util.run_cli("changelog", "--incremental")
    
        with changelog_path.open(encoding="utf-8") as f:
            out = f.read()
    
>       file_regression.check(out, extension=".md")
E       AssertionError: FILES DIFFER:
E       .../popen-gw2/test_changelog_incremental_wit1/test_changelog_incremental_with_release_candidate_version_rc_.md
E       .../popen-gw2/test_changelog_incremental_wit1/test_changelog_incremental_with_release_candidate_version_rc_.obtained.md
E       HTML DIFF: .../popen-gw2/test_changelog_incremental_wit1/test_changelog_incremental_with_release_candidate_version_rc_.obtained.diff.html
E       --- 
E       +++ 
E       @@ -1,9 +1,3 @@
E       -# Changelog
E       -All notable changes to this project will be documented in this file.
E       -
E       -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
E       -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
E       -
E        ## Unreleased
E        
E        ### Feat
E       @@ -24,17 +18,4 @@
E        
E        - output glitch
E        
E       -## [1.0.0] - 2017-06-20
E       -### Added
E       -- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
E       -- Version navigation.
E       -
E       -### Changed
E       -- Start using "changelog" over "change log" since it's the common usage.
E       -
E       -### Removed
E       -- Section about "changelog" vs "CHANGELOG".
E       -
E       -## [0.3.0] - 2015-12-03
E       -### Added
E       -- RU translation from [@aishek](https://github.com/aishek).
E       +## 1.0.0 (2021-06-11)

.../tests/commands/test_changelog_command.py:691: AssertionError
tests/test_bump_create_commit_message.py::test_bump_with_build_metadata
Stack Traces | 0.19s run time
util = UtilFixture(mocker=<pytest_mock.plugin.MockerFixture object at 0x7f8b7e1702c0>, monkeypatch=<_pytest.monkeypatch.MonkeyPatch object at 0x7f8b7e167770>, freezer=<freezegun.api.FrozenDateTimeFactory object at 0x7f8b7e08f6b0>)

    @pytest.mark.usefixtures("tmp_commitizen_project")
    def test_bump_with_build_metadata(util: UtilFixture):
        def _add_entry(test_str: str, args: list):
            Path(test_str).write_text("")
            cmd.run("git add -A")
            cmd.run(f'git commit -m "fix: test-{test_str}"')
            cz_args = ["bump", "--changelog", "--yes"] + args
            util.run_cli(*cz_args)
    
        util.freezer.move_to("2024-01-01")
    
        _add_entry("a", ["--build-metadata", "a.b.c"])
        _add_entry("b", [])
        _add_entry("c", ["--build-metadata", "alongmetadatastring"])
        _add_entry("d", [])
    
        # Pre-commit fixed last line adding extra indent and "\" char
>       assert Path("CHANGELOG.md").read_text() == dedent(
            """\
            ## 0.1.4 (2024-01-01)
    
            ### Fix
    
            - test-d
    
            ## 0.1.3+alongmetadatastring (2024-01-01)
    
            ### Fix
    
            - test-c
    
            ## 0.1.2 (2024-01-01)
    
            ### Fix
    
            - test-b
    
            ## 0.1.1+a.b.c (2024-01-01)
    
            ### Fix
    
            - test-a
            """
        )
E       AssertionError: assert '## 0.1.4 (20...n\n- test-a\n' == '## 0.1.4 (20...n\n- test-a\n'
E         
E         Skipping 155 identical leading characters in diff, use -v to show
E         - a.b.c (2024-01-01)
E         ?           ^  ^  ^
E         + a.b.c (2026-02-07)
E         ?           ^  ^  ^
E           
E           ### Fix
E           
E           - test-a

.../commitizen/tests/test_bump_create_commit_message.py:133: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from d4894e5 to 45b9352 Compare February 29, 2024 18:25
@josix josix marked this pull request as ready for review March 8, 2024 08:34
@josix josix requested a review from woile March 8, 2024 11:40
@noirbizarre
Copy link
Member

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.

@josix
Copy link
Contributor Author

josix commented Mar 11, 2024

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.

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.

@woile
Copy link
Member

woile commented Mar 15, 2024

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

@Lee-W
Copy link
Member

Lee-W commented Mar 30, 2024

I'm a bit confused here. I thought we could solve it by reading the value from config?

@josix
Copy link
Contributor Author

josix commented Apr 1, 2024

I thought we could solve it by reading the value from config?

I think there are total three combinations of configurations here:

  1. user didn't specify changelog_incremental, the Config would store the value as False and the value passing into Changelog should be True
  2. user did specify changelog_increamental: true, the Config would store the value as True, so the value passing into Changelog would also be True
  3. user did specify changelog_increamental: false, the Config would store the value as False, so the value passing into Changelog would also be False

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.

@Lee-W
Copy link
Member

Lee-W commented Apr 2, 2024

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?

@Lowaiz
Copy link
Contributor

Lowaiz commented Nov 29, 2024

Hello,

Do you guys have any news on this fix ?
This setting is blocking the changelog_merge_prerelease option, as the arg incremental take the precedence, causing us to split the bump and the changelog generation in order to have proper release changelog with every changes from release-x to release-x+1 concatenated, and not with every intermediate pre-release.

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably won't say I love this idea, but it is an acceptable workaround before we introduce a better config system. @josix, could you please rebase it and add some tests to verify it?

@Lee-W Lee-W modified the milestones: 4.9.1, 4.9.2 Sep 9, 2025
@Lee-W Lee-W marked this pull request as draft November 8, 2025 08:55
@bearomorphism
Copy link
Collaborator

@josix what is the status of this PR? Thanks!

@josix
Copy link
Contributor Author

josix commented Jan 6, 2026

Oh I missed this comment, let me pick this up

@bearomorphism
Copy link
Collaborator

Thanks!

@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from d439c38 to aef2004 Compare February 4, 2026 13:15
@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from c2df766 to 5ecaa15 Compare February 4, 2026 14:23
@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from 5ecaa15 to 7162151 Compare February 4, 2026 15:37
@josix josix force-pushed the fix/changelog-default-changelog-incremental branch from 7162151 to 9c8f89a Compare February 4, 2026 15:46
Comment on lines 318 to 320
"incremental": incremental_setting
if incremental_setting is not None
else True,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably also works and is less confusing

Suggested change
"incremental": incremental_setting
if incremental_setting is not None
else True,
"incremental": self.config.settings.get("changelog_incremental", True),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks for pointing it out.

Copy link
Contributor Author

@josix josix Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, seems that it will let tests fail, let me investigate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

changelog_incremental is set as default when calling changelog from cz bump

6 participants