From d20aa85a7e2d3bbfd982f752631ea93145390136 Mon Sep 17 00:00:00 2001 From: Jeffrey James Date: Sun, 11 Jul 2021 16:06:21 -0400 Subject: [PATCH 1/9] fix: capitalize types in default change_type_order --- commitizen/defaults.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 35a518adc9..f6b6dee1c3 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -80,10 +80,8 @@ class Settings(TypedDict, total=False): (r"^perf", PATCH), ) ) -change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"] - +change_type_order = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"] bump_message = "bump: version $current_version → $new_version" - commit_parser = r"^(?Pfeat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P[^()\r\n]*)\)|\()?(?P!)?:\s(?P.*)?" # noqa version_parser = r"(?P([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)" From adcdce5c77a859c529ac8843ac98e46503461bda Mon Sep 17 00:00:00 2001 From: Jeffrey James Date: Sun, 11 Jul 2021 16:51:42 -0400 Subject: [PATCH 2/9] docs(customization): update default change_type_order --- docs/customization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/customization.md b/docs/customization.md index 92610f4585..053dbc1230 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -158,7 +158,7 @@ commitizen: | `info` | `str` | `None` | (OPTIONAL) Explanation of the commit rules. Used by `cz info`. | | `bump_map` | `dict` | `None` | (OPTIONAL) Dictionary mapping the extracted information to a `SemVer` increment type (`MAJOR`, `MINOR`, `PATCH`) | | `bump_pattern` | `str` | `None` | (OPTIONAL) Regex to extract information from commit (subject and body) | -| `change_type_order` | `str` | `None` | (OPTIONAL) List of strings used to order the Changelog. All other types will be sorted alphabetically. Default is `["BREAKING CHANGE", "feat", "fix", "refactor", "perf"]` | +| `change_type_order`| `str` | `None` | (OPTIONAL) List of strings used to order the Changelog. All other types will be sorted alphabetically. Default is `["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]` | | `commit_parser` | `str` | `None` | (OPTIONAL) Regex to extract information used in creating changelog. [See more][changelog-spec] | | `changelog_pattern` | `str` | `None` | (OPTIONAL) Regex to understand which commits to include in the changelog | | `change_type_map` | `dict` | `None` | (OPTIONAL) Dictionary mapping the type of the commit to a changelog entry | From 00930e681f8b20a13d124e9257bd8469c20ac2f5 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 30 Mar 2022 15:51:05 +0800 Subject: [PATCH 3/9] fix(changelog): use defaults.change_type_order in conventional commit --- commitizen/commands/changelog.py | 6 ++++-- ...g_incremental_with_release_candidate_version_alpha_.md | 8 ++++---- ...og_incremental_with_release_candidate_version_beta_.md | 8 ++++---- ...elog_incremental_with_release_candidate_version_rc_.md | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/commitizen/commands/changelog.py b/commitizen/commands/changelog.py index 3790dd0c8b..d8d8768c81 100644 --- a/commitizen/commands/changelog.py +++ b/commitizen/commands/changelog.py @@ -3,7 +3,7 @@ from operator import itemgetter from typing import Callable, Dict, List, Optional -from commitizen import changelog, factory, git, out +from commitizen import changelog, defaults, factory, git, out from commitizen.config import BaseConfig from commitizen.exceptions import ( DryRunExit, @@ -45,7 +45,9 @@ def __init__(self, config: BaseConfig, args): self.config.settings.get("change_type_map") or self.cz.change_type_map ) self.change_type_order = ( - self.config.settings.get("change_type_order") or self.cz.change_type_order + self.config.settings.get("change_type_order") + or self.cz.change_type_order + or defaults.change_type_order ) self.rev_range = args.get("rev_range") self.tag_format = args.get("tag_format") or self.config.settings.get( diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_alpha_.md b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_alpha_.md index 1fd5ca870d..9a598e69c8 100644 --- a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_alpha_.md +++ b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_alpha_.md @@ -16,14 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.2.0a0 (2021-06-11) -### Fix - -- output glitch - ### Feat - add new output +### Fix + +- output glitch + ## [1.0.0] - 2017-06-20 ### Added - New visual identity by [@tylerfortune8](https://github.com/tylerfortune8). diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_beta_.md b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_beta_.md index 6ef1c0daad..1f8de4f8f0 100644 --- a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_beta_.md +++ b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_beta_.md @@ -16,14 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.2.0b0 (2021-06-11) -### Fix - -- output glitch - ### Feat - add new output +### Fix + +- output glitch + ## [1.0.0] - 2017-06-20 ### Added - New visual identity by [@tylerfortune8](https://github.com/tylerfortune8). diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_rc_.md b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_rc_.md index 1898179dbf..3ba4eb2d36 100644 --- a/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_rc_.md +++ b/tests/commands/test_changelog_command/test_changelog_incremental_with_release_candidate_version_rc_.md @@ -16,14 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.2.0rc0 (2021-06-11) -### Fix - -- output glitch - ### Feat - add new output +### Fix + +- output glitch + ## [1.0.0] - 2017-06-20 ### Added - New visual identity by [@tylerfortune8](https://github.com/tylerfortune8). From be115cd3ff0914e9ac5afcafe371132a8fd50819 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 30 Mar 2022 16:19:50 +0800 Subject: [PATCH 4/9] test(changelog): refactor test cases through file regression --- tests/commands/test_changelog_command.py | 96 +++++++------------ .../test_breaking_change_content_v1.md | 10 ++ .../test_breaking_change_content_v1_beta.md | 10 ++ ...st_breaking_change_content_v1_multiline.md | 11 +++ .../test_changelog_config_flag_increment.md | 7 ++ .../test_changelog_config_start_rev_option.md | 7 ++ .../test_changelog_from_start.md | 9 ++ ...t_changelog_from_version_zero_point_two.md | 7 ++ ...st_changelog_incremental_angular_sample.md | 16 ++++ ...log_incremental_keep_a_changelog_sample.md | 32 +++++++ ...hangelog_is_persisted_using_incremental.md | 21 ++++ ...ltiple_incremental_do_not_add_new_lines.md | 11 +++ ..._replacing_unreleased_using_incremental.md | 19 ++++ .../test_changelog_with_different_cz.md | 6 ++ 14 files changed, 202 insertions(+), 60 deletions(-) create mode 100644 tests/commands/test_changelog_command/test_breaking_change_content_v1.md create mode 100644 tests/commands/test_changelog_command/test_breaking_change_content_v1_beta.md create mode 100644 tests/commands/test_changelog_command/test_breaking_change_content_v1_multiline.md create mode 100644 tests/commands/test_changelog_command/test_changelog_config_flag_increment.md create mode 100644 tests/commands/test_changelog_command/test_changelog_config_start_rev_option.md create mode 100644 tests/commands/test_changelog_command/test_changelog_from_start.md create mode 100644 tests/commands/test_changelog_command/test_changelog_from_version_zero_point_two.md create mode 100644 tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md create mode 100644 tests/commands/test_changelog_command/test_changelog_incremental_keep_a_changelog_sample.md create mode 100644 tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md create mode 100644 tests/commands/test_changelog_command/test_changelog_multiple_incremental_do_not_add_new_lines.md create mode 100644 tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md create mode 100644 tests/commands/test_changelog_command/test_changelog_with_different_cz.md diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index e3c4a5665a..73eedb589c 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -1,5 +1,4 @@ import sys -from datetime import date import pytest @@ -27,7 +26,7 @@ def test_changelog_on_empty_project(mocker): @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_from_version_zero_point_two(mocker, capsys): +def test_changelog_from_version_zero_point_two(mocker, capsys, file_regression): create_file_and_commit("feat: new file") create_file_and_commit("refactor: not in changelog") @@ -46,11 +45,11 @@ def test_changelog_from_version_zero_point_two(mocker, capsys): cli.main() out, _ = capsys.readouterr() - assert out == "## Unreleased\n\n### Feat\n\n- after 0.2\n- after 0.2.0\n\n" + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_with_different_cz(mocker, capsys): +def test_changelog_with_different_cz(mocker, capsys, file_regression): create_file_and_commit("JRA-34 #comment corrected indent issue") create_file_and_commit("JRA-35 #time 1w 2d 4h 30m Total work logged") @@ -60,14 +59,11 @@ def test_changelog_with_different_cz(mocker, capsys): with pytest.raises(DryRunExit): cli.main() out, _ = capsys.readouterr() - assert ( - out - == "## Unreleased\n\n\n- JRA-35 #time 1w 2d 4h 30m Total work logged\n- JRA-34 #comment corrected indent issue\n\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_from_start(mocker, capsys, changelog_path): +def test_changelog_from_start(mocker, capsys, changelog_path, file_regression): create_file_and_commit("feat: new file") create_file_and_commit("refactor: is in changelog") create_file_and_commit("Merge into master") @@ -78,16 +74,12 @@ def test_changelog_from_start(mocker, capsys, changelog_path): with open(changelog_path, "r") as f: out = f.read() - - assert ( - out - == "## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_replacing_unreleased_using_incremental( - mocker, capsys, changelog_path + mocker, capsys, changelog_path, file_regression ): create_file_and_commit("feat: add new output") create_file_and_commit("fix: output glitch") @@ -112,15 +104,13 @@ def test_changelog_replacing_unreleased_using_incremental( with open(changelog_path, "r") as f: out = f.read() - today = date.today().isoformat() - assert ( - out - == f"## Unreleased\n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_is_persisted_using_incremental(mocker, capsys, changelog_path): +def test_changelog_is_persisted_using_incremental( + mocker, capsys, changelog_path, file_regression +): create_file_and_commit("feat: add new output") create_file_and_commit("fix: output glitch") @@ -149,15 +139,13 @@ def test_changelog_is_persisted_using_incremental(mocker, capsys, changelog_path with open(changelog_path, "r") as f: out = f.read() - today = date.today().isoformat() - assert ( - out - == f"## Unreleased\n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n\nnote: this should be persisted using increment\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_incremental_angular_sample(mocker, capsys, changelog_path): +def test_changelog_incremental_angular_sample( + mocker, capsys, changelog_path, file_regression +): with open(changelog_path, "w") as f: f.write( "# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22)\n" @@ -183,10 +171,7 @@ def test_changelog_incremental_angular_sample(mocker, capsys, changelog_path): with open(changelog_path, "r") as f: out = f.read() - assert ( - out - == "## Unreleased\n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22)\n\n### Bug Fixes\n* **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566)\n" - ) + file_regression.check(out, extension=".md") KEEP_A_CHANGELOG = """# Changelog @@ -215,7 +200,9 @@ def test_changelog_incremental_angular_sample(mocker, capsys, changelog_path): @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_incremental_keep_a_changelog_sample(mocker, capsys, changelog_path): +def test_changelog_incremental_keep_a_changelog_sample( + mocker, capsys, changelog_path, file_regression +): with open(changelog_path, "w") as f: f.write(KEEP_A_CHANGELOG) create_file_and_commit("irrelevant commit") @@ -235,10 +222,7 @@ def test_changelog_incremental_keep_a_changelog_sample(mocker, capsys, changelog with open(changelog_path, "r") as f: out = f.read() - assert ( - out - == """# Changelog\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## Unreleased\n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n## [1.0.0] - 2017-06-20\n### Added\n- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).\n- Version navigation.\n\n### Changed\n- Start using "changelog" over "change log" since it\'s the common usage.\n\n### Removed\n- Section about "changelog" vs "CHANGELOG".\n\n## [0.3.0] - 2015-12-03\n### Added\n- RU translation from [@aishek](https://github.com/aishek).\n""" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") @@ -287,7 +271,7 @@ def test_changelog_hook_customize(mocker, config_customize): @pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_multiple_incremental_do_not_add_new_lines( - mocker, capsys, changelog_path + mocker, capsys, changelog_path, file_regression ): """Test for bug https://github.com/commitizen-tools/commitizen/issues/192""" create_file_and_commit("feat: add new output") @@ -317,7 +301,7 @@ def test_changelog_multiple_incremental_do_not_add_new_lines( with open(changelog_path, "r") as f: out = f.read() - assert out.startswith("#") + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") @@ -394,7 +378,7 @@ def test_changelog_in_non_git_project(tmpdir, config, mocker): @pytest.mark.usefixtures("tmp_commitizen_project") -def test_breaking_change_content_v1_beta(mocker, capsys): +def test_breaking_change_content_v1_beta(mocker, capsys, file_regression): commit_message = ( "feat(users): email pattern corrected\n\n" "BREAKING CHANGE: migrate by renaming user to users\n\n" @@ -406,15 +390,11 @@ def test_breaking_change_content_v1_beta(mocker, capsys): with pytest.raises(DryRunExit): cli.main() out, _ = capsys.readouterr() - - assert out == ( - "## Unreleased\n\n### Feat\n\n- **users**: email pattern corrected\n\n" - "### BREAKING CHANGE\n\n- migrate by renaming user to users\n\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_breaking_change_content_v1(mocker, capsys): +def test_breaking_change_content_v1(mocker, capsys, file_regression): commit_message = ( "feat(users): email pattern corrected\n\n" "body content\n\n" @@ -427,14 +407,11 @@ def test_breaking_change_content_v1(mocker, capsys): cli.main() out, _ = capsys.readouterr() - assert out == ( - "## Unreleased\n\n### Feat\n\n- **users**: email pattern corrected\n\n" - "### BREAKING CHANGE\n\n- migrate by renaming user to users\n\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_breaking_change_content_v1_multiline(mocker, capsys): +def test_breaking_change_content_v1_multiline(mocker, capsys, file_regression): commit_message = ( "feat(users): email pattern corrected\n\n" "body content\n\n" @@ -448,17 +425,13 @@ def test_breaking_change_content_v1_multiline(mocker, capsys): with pytest.raises(DryRunExit): cli.main() out, _ = capsys.readouterr() - - assert out == ( - "## Unreleased\n\n### Feat\n\n- **users**: email pattern corrected\n\n" - "### BREAKING CHANGE\n\n- migrate by renaming user to users.\n" - "and then connect the thingy with the other thingy" - "\n\n" - ) + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_config_flag_increment(mocker, changelog_path, config_path): +def test_changelog_config_flag_increment( + mocker, changelog_path, config_path, file_regression +): with open(config_path, "a") as f: f.write("changelog_incremental = true\n") @@ -475,10 +448,13 @@ def test_changelog_config_flag_increment(mocker, changelog_path, config_path): out = f.read() assert "this should be persisted using increment" in out + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") -def test_changelog_config_start_rev_option(mocker, capsys, config_path): +def test_changelog_config_start_rev_option( + mocker, capsys, config_path, file_regression +): # create commit and tag create_file_and_commit("feat: new file") @@ -499,7 +475,7 @@ def test_changelog_config_start_rev_option(mocker, capsys, config_path): cli.main() out, _ = capsys.readouterr() - assert out == "## Unreleased\n\n### Feat\n\n- after 0.2\n- after 0.2.0\n\n" + file_regression.check(out, extension=".md") @pytest.mark.usefixtures("tmp_commitizen_project") diff --git a/tests/commands/test_changelog_command/test_breaking_change_content_v1.md b/tests/commands/test_changelog_command/test_breaking_change_content_v1.md new file mode 100644 index 0000000000..c4809739a9 --- /dev/null +++ b/tests/commands/test_changelog_command/test_breaking_change_content_v1.md @@ -0,0 +1,10 @@ +## Unreleased + +### BREAKING CHANGE + +- migrate by renaming user to users + +### Feat + +- **users**: email pattern corrected + diff --git a/tests/commands/test_changelog_command/test_breaking_change_content_v1_beta.md b/tests/commands/test_changelog_command/test_breaking_change_content_v1_beta.md new file mode 100644 index 0000000000..c4809739a9 --- /dev/null +++ b/tests/commands/test_changelog_command/test_breaking_change_content_v1_beta.md @@ -0,0 +1,10 @@ +## Unreleased + +### BREAKING CHANGE + +- migrate by renaming user to users + +### Feat + +- **users**: email pattern corrected + diff --git a/tests/commands/test_changelog_command/test_breaking_change_content_v1_multiline.md b/tests/commands/test_changelog_command/test_breaking_change_content_v1_multiline.md new file mode 100644 index 0000000000..7becef3dc3 --- /dev/null +++ b/tests/commands/test_changelog_command/test_breaking_change_content_v1_multiline.md @@ -0,0 +1,11 @@ +## Unreleased + +### BREAKING CHANGE + +- migrate by renaming user to users. +and then connect the thingy with the other thingy + +### Feat + +- **users**: email pattern corrected + diff --git a/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md b/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md new file mode 100644 index 0000000000..149dc57767 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md @@ -0,0 +1,7 @@ + +note: this should be persisted using increment +## Unreleased + +### Feat + +- add new output diff --git a/tests/commands/test_changelog_command/test_changelog_config_start_rev_option.md b/tests/commands/test_changelog_command/test_changelog_config_start_rev_option.md new file mode 100644 index 0000000000..d1baef26aa --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_config_start_rev_option.md @@ -0,0 +1,7 @@ +## Unreleased + +### Feat + +- after 0.2 +- after 0.2.0 + diff --git a/tests/commands/test_changelog_command/test_changelog_from_start.md b/tests/commands/test_changelog_command/test_changelog_from_start.md new file mode 100644 index 0000000000..bdc78660d5 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_from_start.md @@ -0,0 +1,9 @@ +## Unreleased + +### Feat + +- new file + +### Refactor + +- is in changelog diff --git a/tests/commands/test_changelog_command/test_changelog_from_version_zero_point_two.md b/tests/commands/test_changelog_command/test_changelog_from_version_zero_point_two.md new file mode 100644 index 0000000000..d1baef26aa --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_from_version_zero_point_two.md @@ -0,0 +1,7 @@ +## Unreleased + +### Feat + +- after 0.2 +- after 0.2.0 + diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md b/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md new file mode 100644 index 0000000000..ea4c57c974 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md @@ -0,0 +1,16 @@ +## Unreleased + +### Feat + +- add more stuff +- add new output + +### Fix + +- mama gotta work +- output glitch + +# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22) + +### Bug Fixes +* **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566) diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_keep_a_changelog_sample.md b/tests/commands/test_changelog_command/test_changelog_incremental_keep_a_changelog_sample.md new file mode 100644 index 0000000000..56e2cf81f5 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_incremental_keep_a_changelog_sample.md @@ -0,0 +1,32 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +### Feat + +- add more stuff +- add new output + +### Fix + +- mama gotta work +- output glitch + +## [1.0.0] - 2017-06-20 +### Added +- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8). +- Version navigation. + +### Changed +- Start using "changelog" over "change log" since it's the common usage. + +### Removed +- Section about "changelog" vs "CHANGELOG". + +## [0.3.0] - 2015-12-03 +### Added +- RU translation from [@aishek](https://github.com/aishek). diff --git a/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md b/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md new file mode 100644 index 0000000000..94f61d3a86 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md @@ -0,0 +1,21 @@ +## Unreleased + +### Feat + +- add more stuff + +### Fix + +- mama gotta work + +## 0.2.0 (2022-03-30) + +### Feat + +- add new output + +### Fix + +- output glitch + +note: this should be persisted using increment diff --git a/tests/commands/test_changelog_command/test_changelog_multiple_incremental_do_not_add_new_lines.md b/tests/commands/test_changelog_command/test_changelog_multiple_incremental_do_not_add_new_lines.md new file mode 100644 index 0000000000..85834c2d38 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_multiple_incremental_do_not_add_new_lines.md @@ -0,0 +1,11 @@ +## Unreleased + +### Feat + +- add more stuff +- add new output + +### Fix + +- no more explosions +- output glitch diff --git a/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md b/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md new file mode 100644 index 0000000000..045e63abf7 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md @@ -0,0 +1,19 @@ +## Unreleased + +### Feat + +- add more stuff + +### Fix + +- mama gotta work + +## 0.2.0 (2022-03-30) + +### Feat + +- add new output + +### Fix + +- output glitch diff --git a/tests/commands/test_changelog_command/test_changelog_with_different_cz.md b/tests/commands/test_changelog_command/test_changelog_with_different_cz.md new file mode 100644 index 0000000000..e9d306236a --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_with_different_cz.md @@ -0,0 +1,6 @@ +## Unreleased + + +- JRA-35 #time 1w 2d 4h 30m Total work logged +- JRA-34 #comment corrected indent issue + From 74a69222a97aafffa6015ccecac7342f134593d9 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 14 Aug 2022 12:54:01 +0800 Subject: [PATCH 5/9] feat: new file --- 701a8810-6c9c-4b1c-a037-1894fbecb80d | 0 pyproject.toml | 2 + tests/commands/test_changelog_command.py | 44 +++++++++++++++++++ ...gelog_with_customized_change_type_order.md | 20 +++++++++ 4 files changed, 66 insertions(+) create mode 100644 701a8810-6c9c-4b1c-a037-1894fbecb80d create mode 100644 tests/commands/test_changelog_command/test_changelog_with_customized_change_type_order.md diff --git a/701a8810-6c9c-4b1c-a037-1894fbecb80d b/701a8810-6c9c-4b1c-a037-1894fbecb80d new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pyproject.toml b/pyproject.toml index f565e95279..2904b44dcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -132,3 +132,5 @@ known_first_party = ["commitizen", "tests"] [build-system] requires = ["poetry_core>=1.0.0"] build-backend = "poetry.core.masonry.api" +tag_format = "$version" +change_type_order = ["BREAKING CHANGE", "Perf", "Fix", "Feat", "Refactor"] diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index 73eedb589c..47a36cb39c 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -866,3 +866,47 @@ def test_invalid_subject_is_skipped(mocker, capsys): out, _ = capsys.readouterr() assert out == ("## Unreleased\n\n### Feat\n\n- a new world\n\n") + + +@pytest.mark.freeze_time("2022-02-13") +def test_changelog_with_customized_change_type_order( + mocker, config_path, changelog_path, file_regression +): + mocker.patch("commitizen.git.GitTag.date", "2022-02-13") + + with open(config_path, "a") as f: + f.write('tag_format = "$version"\n') + f.write( + 'change_type_order = ["BREAKING CHANGE", "Perf", "Fix", "Feat", "Refactor"]\n' + ) + + # create commit and tag + create_file_and_commit("feat: new file") + testargs = ["cz", "bump", "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + wait_for_tag() + create_file_and_commit("feat: after 0.2.0") + create_file_and_commit("feat: another feature") + create_file_and_commit("fix: fix bug") + + testargs = ["cz", "bump", "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + wait_for_tag() + + create_file_and_commit("feat: getting ready for this") + create_file_and_commit("perf: perf improvement") + + testargs = ["cz", "bump", "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + wait_for_tag() + + testargs = ["cz", "changelog", "0.3.0..0.4.0"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + with open(changelog_path, "r") as f: + out = f.read() + + file_regression.check(out, extension=".md") diff --git a/tests/commands/test_changelog_command/test_changelog_with_customized_change_type_order.md b/tests/commands/test_changelog_command/test_changelog_with_customized_change_type_order.md new file mode 100644 index 0000000000..358908ea29 --- /dev/null +++ b/tests/commands/test_changelog_command/test_changelog_with_customized_change_type_order.md @@ -0,0 +1,20 @@ +## 0.4.0 (2022-02-13) + +### Perf + +- perf improvement + +### Feat + +- getting ready for this + +## 0.3.0 (2022-02-13) + +### Fix + +- fix bug + +### Feat + +- another feature +- after 0.2.0 From 0a52cf9e1ae93679607dc9948126b26f01a8574f Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 30 Mar 2022 16:32:10 +0800 Subject: [PATCH 6/9] test(changelog): add test case for customized change_type_order --- tests/commands/test_changelog_command.py | 3 +++ .../test_changelog_config_flag_increment.md | 1 + .../test_changelog_is_persisted_using_incremental.md | 2 +- .../test_changelog_replacing_unreleased_using_incremental.md | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index 47a36cb39c..ed6aa6194e 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -78,6 +78,7 @@ def test_changelog_from_start(mocker, capsys, changelog_path, file_regression): @pytest.mark.usefixtures("tmp_commitizen_project") +@pytest.mark.freeze_time("2022-03-30") def test_changelog_replacing_unreleased_using_incremental( mocker, capsys, changelog_path, file_regression ): @@ -108,6 +109,7 @@ def test_changelog_replacing_unreleased_using_incremental( @pytest.mark.usefixtures("tmp_commitizen_project") +@pytest.mark.freeze_time("2022-03-30") def test_changelog_is_persisted_using_incremental( mocker, capsys, changelog_path, file_regression ): @@ -869,6 +871,7 @@ def test_invalid_subject_is_skipped(mocker, capsys): @pytest.mark.freeze_time("2022-02-13") +@pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_with_customized_change_type_order( mocker, config_path, changelog_path, file_regression ): diff --git a/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md b/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md index 149dc57767..5bdace3053 100644 --- a/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md +++ b/tests/commands/test_changelog_command/test_changelog_config_flag_increment.md @@ -1,5 +1,6 @@ note: this should be persisted using increment + ## Unreleased ### Feat diff --git a/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md b/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md index 94f61d3a86..721d11d8cb 100644 --- a/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md +++ b/tests/commands/test_changelog_command/test_changelog_is_persisted_using_incremental.md @@ -8,7 +8,7 @@ - mama gotta work -## 0.2.0 (2022-03-30) +## 0.2.0 (2022-08-14) ### Feat diff --git a/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md b/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md index 045e63abf7..8fca3c6b5e 100644 --- a/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md +++ b/tests/commands/test_changelog_command/test_changelog_replacing_unreleased_using_incremental.md @@ -8,7 +8,7 @@ - mama gotta work -## 0.2.0 (2022-03-30) +## 0.2.0 (2022-08-14) ### Feat From 6be5c419973c115cea0bdfcd8c337b7dee3661b7 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 14 Aug 2022 14:23:05 +0800 Subject: [PATCH 7/9] test: remove test generated file --- 701a8810-6c9c-4b1c-a037-1894fbecb80d | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 701a8810-6c9c-4b1c-a037-1894fbecb80d diff --git a/701a8810-6c9c-4b1c-a037-1894fbecb80d b/701a8810-6c9c-4b1c-a037-1894fbecb80d deleted file mode 100644 index e69de29bb2..0000000000 From 26c25ef20c7eb7b97bfe4f9c7c03cc5785710600 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 14 Aug 2022 14:25:27 +0800 Subject: [PATCH 8/9] fix(pyproject.toml): remove test added configurations --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2904b44dcb..f565e95279 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -132,5 +132,3 @@ known_first_party = ["commitizen", "tests"] [build-system] requires = ["poetry_core>=1.0.0"] build-backend = "poetry.core.masonry.api" -tag_format = "$version" -change_type_order = ["BREAKING CHANGE", "Perf", "Fix", "Feat", "Refactor"] From d33f5fcd63c32ce84a78c100b8f73c633fc0513b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 14 Aug 2022 07:59:29 +0000 Subject: [PATCH 9/9] =?UTF-8?q?bump:=20version=202.30.0=20=E2=86=92=202.31?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 12 ++++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d27cb49b5..e54255193f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: no-commit-to-branch - repo: https://github.com/commitizen-tools/commitizen - rev: v2.30.0 # automatically updated by Commitizen + rev: v2.31.0 # automatically updated by Commitizen hooks: - id: commitizen stages: [commit-msg] diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb30867c6..877954829d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,16 @@ +## v2.31.0 (2022-08-14) + +### Fix + +- **pyproject.toml**: remove test added configurations +- **changelog**: use defaults.change_type_order in conventional commit +- capitalize types in default change_type_order + +### Feat + +- new file + ## v2.30.0 (2022-08-14) ### Feat diff --git a/commitizen/__version__.py b/commitizen/__version__.py index 492171fe38..69453c37cd 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "2.30.0" +__version__ = "2.31.0" diff --git a/pyproject.toml b/pyproject.toml index f565e95279..f040d5eb2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.commitizen] -version = "2.30.0" +version = "2.31.0" tag_format = "v$version" version_files = [ "pyproject.toml:version", @@ -30,7 +30,7 @@ exclude = ''' [tool.poetry] name = "commitizen" -version = "2.30.0" +version = "2.31.0" description = "Python commitizen client tool" authors = ["Santiago Fraire "] license = "MIT"