From 8540e1f3d2a418e34fd14be0ebbae2819314d8b3 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Fri, 30 May 2025 12:10:17 +0800 Subject: [PATCH] refactor(BaseCommitizen): remove unused process_commit --- commitizen/cz/base.py | 7 ------ .../conventional_commits.py | 6 ----- tests/test_cz_base.py | 6 ----- tests/test_cz_conventional_commits.py | 23 ------------------- 4 files changed, 42 deletions(-) diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index 43455a74ca..7463a67c24 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -99,10 +99,3 @@ def schema_pattern(self) -> str: def info(self) -> str: """Information about the standardized commit message.""" raise NotImplementedError("Not Implemented yet") - - def process_commit(self, commit: str) -> str: - """Process commit for changelog. - - If not overwritten, it returns the first line of commit. - """ - return commit.split("\n")[0] diff --git a/commitizen/cz/conventional_commits/conventional_commits.py b/commitizen/cz/conventional_commits/conventional_commits.py index 9a2b9016b7..996d25a42d 100644 --- a/commitizen/cz/conventional_commits/conventional_commits.py +++ b/commitizen/cz/conventional_commits/conventional_commits.py @@ -1,5 +1,4 @@ import os -import re from commitizen import defaults from commitizen.cz.base import BaseCommitizen @@ -198,8 +197,3 @@ def info(self) -> str: filepath = os.path.join(dir_path, "conventional_commits_info.txt") with open(filepath, encoding=self.config.settings["encoding"]) as f: return f.read() - - def process_commit(self, commit: str) -> str: - if m := re.match(self.schema_pattern(), commit): - return m.group(3).strip() - return "" diff --git a/tests/test_cz_base.py b/tests/test_cz_base.py index 4ee1cc6eda..be93b4ca0f 100644 --- a/tests/test_cz_base.py +++ b/tests/test_cz_base.py @@ -42,9 +42,3 @@ def test_info(config): cz = DummyCz(config) with pytest.raises(NotImplementedError): cz.info() - - -def test_process_commit(config): - cz = DummyCz(config) - message = cz.process_commit("test(test_scope): this is test msg") - assert message == "test(test_scope): this is test msg" diff --git a/tests/test_cz_conventional_commits.py b/tests/test_cz_conventional_commits.py index 6d4e0f7435..2a036bf024 100644 --- a/tests/test_cz_conventional_commits.py +++ b/tests/test_cz_conventional_commits.py @@ -130,26 +130,3 @@ def test_info(config): conventional_commits = ConventionalCommitsCz(config) info = conventional_commits.info() assert isinstance(info, str) - - -@pytest.mark.parametrize( - ("commit_message", "expected_message"), - [ - ( - "test(test_scope): this is test msg", - "this is test msg", - ), - ( - "test(test_scope)!: this is test msg", - "this is test msg", - ), - ( - "test!(test_scope): this is test msg", - "", - ), - ], -) -def test_process_commit(commit_message, expected_message, config): - conventional_commits = ConventionalCommitsCz(config) - message = conventional_commits.process_commit(commit_message) - assert message == expected_message