diff --git a/docs/configuration.rst b/docs/configuration.rst index bf4253c2..b4b4a866 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -233,6 +233,17 @@ create patch releases. Default: `:ambulance:, :lock:, :bug:, :zap:, :goal_net:, :alien:, :wheelchair:, :speech_balloon:, :mag:, :apple:, :penguin:, :checkered_flag:, :robot:, :green_apple:` +.. _config-use_textual_changelog_sections: + +``use_textual_changelog_sections`` +------------------------------------ + +If this is set to `true` with using the :py:func:`semantic_release.history.emoji_parser`, +semantic-release will use human readable ASCII section headings in the changelog instead of +the configured emoji. + +Default: `false` + .. _config-scipy-parser: ``scipy_parser`` diff --git a/semantic_release/defaults.cfg b/semantic_release/defaults.cfg index d49e5982..9e1e2aa5 100644 --- a/semantic_release/defaults.cfg +++ b/semantic_release/defaults.cfg @@ -11,6 +11,7 @@ changelog_file=CHANGELOG.md changelog_placeholder= changelog_scope=true changelog_sections=feature,fix,breaking,documentation,performance,:boom:,:sparkles:,:children_crossing:,:lipstick:,:iphone:,:egg:,:chart_with_upwards_trend:,:ambulance:,:lock:,:bug:,:zap:,:goal_net:,:alien:,:wheelchair:,:speech_balloon:,:mag:,:apple:,:penguin:,:checkered_flag:,:robot:,:green_apple:,Other +use_textual_changelog_sections=false check_build_status=false include_additional_files= commit_message=Automatically generated by python-semantic-release diff --git a/semantic_release/history/parser_emoji.py b/semantic_release/history/parser_emoji.py index 6f244b45..4b51430d 100644 --- a/semantic_release/history/parser_emoji.py +++ b/semantic_release/history/parser_emoji.py @@ -39,6 +39,7 @@ def parse_commit_message( patch = config.get("patch_emoji").split(",") all_emojis = major + minor + patch + use_textual_changelog_sections = config.get("use_textual_changelog_sections") # Loop over emojis from most important to least important # Therefore, we find the highest level emoji first primary_emoji = "Other" @@ -52,9 +53,12 @@ def parse_commit_message( level_bump = 0 if primary_emoji in major: level_bump = 3 + primary_emoji = "breaking" if use_textual_changelog_sections else primary_emoji elif primary_emoji in minor: + primary_emoji = "feature" if use_textual_changelog_sections else primary_emoji level_bump = 2 elif primary_emoji in patch: + primary_emoji = "fix" if use_textual_changelog_sections else primary_emoji level_bump = 1 # All emojis will remain part of the returned description diff --git a/semantic_release/settings.py b/semantic_release/settings.py index 7f571147..726e660f 100644 --- a/semantic_release/settings.py +++ b/semantic_release/settings.py @@ -39,6 +39,7 @@ def _config_from_ini(paths): flags = { "changelog_capitalize", "changelog_scope", + "use_textual_changelog_sections", "check_build_status", "commit_version_number", "ignore_token_for_push", diff --git a/tests/parsers/test_emoji.py b/tests/parsers/test_emoji.py index 80b1696b..83cfbe60 100644 --- a/tests/parsers/test_emoji.py +++ b/tests/parsers/test_emoji.py @@ -1,5 +1,10 @@ +import mock +import pytest + from semantic_release.history import emoji_parser +from .. import wrapped_config_get + def test_major(): commit = ( @@ -65,3 +70,35 @@ def test_emoji_in_description(): ":boom: should not be detected", ] assert parsed_commit[4] == [] + + +@mock.patch( + "semantic_release.history.parser_emoji.config.get", + wrapped_config_get(use_textual_changelog_sections=True), +) +@pytest.mark.parametrize( + "level,commit,commit_type", + [ + ( + 3, + ":boom: Breaking changes\n\n" + "More description\n\n" + "Even more description", + "breaking", + ), + ( + 2, + ":sparkles: Add a new feature\n\n" "Some description of the feature", + "feature", + ), + ( + 1, + ":bug: Fixing a bug\n\n" "The bug is finally gone!", + "fix", + ), + ], +) +def test_use_textual_changelog_sections(level, commit, commit_type): + parsed_commit = emoji_parser(commit) + assert parsed_commit[0] == level + assert parsed_commit[1] == commit_type