diff --git a/src/semantic_release/commit_parser/conventional/options.py b/src/semantic_release/commit_parser/conventional/options.py index 6bdb9739c..2cb4c2045 100644 --- a/src/semantic_release/commit_parser/conventional/options.py +++ b/src/semantic_release/commit_parser/conventional/options.py @@ -42,9 +42,6 @@ class ConventionalCommitParserOptions(ParserOptions): one of these prefixes, it will not be considered a valid commit message. """ - default_bump_level: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_squash_commits: bool = True """Toggle flag for whether or not to parse squash commits""" @@ -64,7 +61,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), ] diff --git a/src/semantic_release/commit_parser/conventional/parser.py b/src/semantic_release/commit_parser/conventional/parser.py index 5cab34c56..cd2c3312e 100644 --- a/src/semantic_release/commit_parser/conventional/parser.py +++ b/src/semantic_release/commit_parser/conventional/parser.py @@ -257,9 +257,7 @@ def create_parsed_message_result( level_bump = ( LevelBump.MAJOR if body_components["breaking_descriptions"] or parsed_break - else self.options.tag_to_level.get( - parsed_type, self.options.default_bump_level - ) + else self.options.tag_to_level.get(parsed_type, LevelBump.NO_RELEASE) ) return ParsedMessageResult( diff --git a/src/semantic_release/commit_parser/emoji.py b/src/semantic_release/commit_parser/emoji.py index 801160208..fc8386ac3 100644 --- a/src/semantic_release/commit_parser/emoji.py +++ b/src/semantic_release/commit_parser/emoji.py @@ -76,9 +76,6 @@ class EmojiParserOptions(ParserOptions): ) """All commit-type prefixes that are allowed.""" - default_bump_level: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_linked_issues: bool = False """ Whether to parse linked issues from the commit message. @@ -111,7 +108,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), *zip_longest(self.major_tags, (), fillvalue=LevelBump.MAJOR), @@ -280,9 +277,7 @@ def parse_message(self, message: str) -> ParsedMessageResult: primary_emoji = match.group("type") if match else "Other" parsed_scope = (match.group("scope") if match else None) or "" - level_bump = self.options.tag_to_level.get( - primary_emoji, self.options.default_bump_level - ) + level_bump = self.options.tag_to_level.get(primary_emoji, LevelBump.NO_RELEASE) # All emojis will remain part of the returned description body_components: dict[str, list[str]] = reduce( diff --git a/src/semantic_release/commit_parser/scipy.py b/src/semantic_release/commit_parser/scipy.py index e6988ea83..6fef82a58 100644 --- a/src/semantic_release/commit_parser/scipy.py +++ b/src/semantic_release/commit_parser/scipy.py @@ -145,10 +145,6 @@ class ScipyParserOptions(ParserOptions): one of these prefixes, it will not be considered a valid commit message. """ - # TODO: breaking v11, make consistent with AngularParserOptions - default_level_bump: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_squash_commits: bool = True """Toggle flag for whether or not to parse squash commits""" @@ -161,8 +157,6 @@ def tag_to_level(self) -> dict[str, LevelBump]: return self._tag_to_level def __post_init__(self) -> None: - # TODO: breaking v11, remove as the name is now consistent - self.default_bump_level = self.default_level_bump self._tag_to_level: dict[str, LevelBump] = { str(tag): level for tag, level in [ @@ -170,7 +164,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), *zip_longest(self.major_tags, (), fillvalue=LevelBump.MAJOR), @@ -347,9 +341,7 @@ def parse_message(self, message: str) -> ParsedMessageResult | None: }, ) - level_bump = self.options.tag_to_level.get( - parsed_type, self.options.default_bump_level - ) + level_bump = self.options.tag_to_level.get(parsed_type, LevelBump.NO_RELEASE) return ParsedMessageResult( bump=level_bump, diff --git a/tests/unit/semantic_release/cli/test_config.py b/tests/unit/semantic_release/cli/test_config.py index 343748187..972cb0a34 100644 --- a/tests/unit/semantic_release/cli/test_config.py +++ b/tests/unit/semantic_release/cli/test_config.py @@ -30,7 +30,6 @@ from semantic_release.commit_parser.scipy import ScipyParserOptions from semantic_release.commit_parser.tag import TagParserOptions from semantic_release.const import DEFAULT_COMMIT_AUTHOR -from semantic_release.enums import LevelBump from semantic_release.errors import ParserLoadError from tests.fixtures.repos import repo_w_no_tags_conventional_commits @@ -138,7 +137,6 @@ def test_load_user_defined_parser_opts(): "allowed_tags": ["foo", "bar", "baz"], "minor_tags": ["bar"], "patch_tags": ["baz"], - "default_bump_level": LevelBump.PATCH.value, } raw_config = RawConfig.model_validate( { diff --git a/tests/unit/semantic_release/commit_parser/test_conventional.py b/tests/unit/semantic_release/commit_parser/test_conventional.py index 9298c1f24..0f7f20169 100644 --- a/tests/unit/semantic_release/commit_parser/test_conventional.py +++ b/tests/unit/semantic_release/commit_parser/test_conventional.py @@ -1116,8 +1116,9 @@ def test_parser_return_release_notices_from_commit_message( ############################## # test custom parser options # ############################## -def test_parser_custom_default_level(make_commit_obj: MakeCommitObjFn): - options = ConventionalCommitParserOptions(default_bump_level=LevelBump.MINOR) +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = ConventionalCommitParserOptions() parsed_results = ConventionalCommitParser(options).parse( make_commit_obj("test(parser): add a test for conventional parser") ) @@ -1126,7 +1127,7 @@ def test_parser_custom_default_level(make_commit_obj: MakeCommitObjFn): result = next(iter(parsed_results)) assert isinstance(result, ParsedCommit) - assert result.bump is LevelBump.MINOR + assert result.bump is LevelBump.NO_RELEASE def test_parser_custom_allowed_types( diff --git a/tests/unit/semantic_release/commit_parser/test_emoji.py b/tests/unit/semantic_release/commit_parser/test_emoji.py index c477579ec..558dba01a 100644 --- a/tests/unit/semantic_release/commit_parser/test_emoji.py +++ b/tests/unit/semantic_release/commit_parser/test_emoji.py @@ -1073,3 +1073,17 @@ def test_parser_ignore_merge_commit( assert isinstance(parsed_result, ParseError) assert "Ignoring merge commit" in parsed_result.error + + +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = EmojiParserOptions() + parsed_results = EmojiCommitParser(options).parse( + make_commit_obj(":memo: add documentation for emoji parser") + ) + + assert isinstance(parsed_results, Iterable) + + result = next(iter(parsed_results)) + assert isinstance(result, ParsedCommit) + assert result.bump is LevelBump.NO_RELEASE diff --git a/tests/unit/semantic_release/commit_parser/test_scipy.py b/tests/unit/semantic_release/commit_parser/test_scipy.py index ce714c0bc..49313c014 100644 --- a/tests/unit/semantic_release/commit_parser/test_scipy.py +++ b/tests/unit/semantic_release/commit_parser/test_scipy.py @@ -1361,3 +1361,17 @@ def test_parser_ignore_merge_commit( assert isinstance(parsed_result, ParseError) assert "Ignoring merge commit" in parsed_result.error + + +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = ScipyParserOptions() + parsed_results = ScipyCommitParser(options).parse( + make_commit_obj("TST: add a test for scipy parser") + ) + + assert isinstance(parsed_results, Iterable) + + result = next(iter(parsed_results)) + assert isinstance(result, ParsedCommit) + assert result.bump is LevelBump.NO_RELEASE