diff --git a/webhook_server/libs/pull_request_handler.py b/webhook_server/libs/pull_request_handler.py index f5aa2a09..2a890f2a 100644 --- a/webhook_server/libs/pull_request_handler.py +++ b/webhook_server/libs/pull_request_handler.py @@ -62,6 +62,9 @@ async def process_pull_request_webhook_data(self, pull_request: PullRequest) -> if hook_action == "edited": await self.set_wip_label_based_on_title(pull_request=pull_request) + if self.hook_data["changes"].get("title"): + self.logger.info(f"{self.log_prefix} PR title changed, running conventional title check") + await self.runner_handler.run_conventional_title_check(pull_request=pull_request) if hook_action in ("opened", "reopened", "ready_for_review"): tasks: list[Coroutine[Any, Any, Any]] = [] diff --git a/webhook_server/tests/test_pull_request_handler.py b/webhook_server/tests/test_pull_request_handler.py index 50465f2a..b6392291 100644 --- a/webhook_server/tests/test_pull_request_handler.py +++ b/webhook_server/tests/test_pull_request_handler.py @@ -88,11 +88,26 @@ async def test_process_pull_request_webhook_data_edited_action( ) -> None: """Test processing pull request webhook data when action is edited.""" pull_request_handler.hook_data["action"] = "edited" + pull_request_handler.hook_data["changes"] = {} with patch.object(pull_request_handler, "set_wip_label_based_on_title") as mock_set_wip: await pull_request_handler.process_pull_request_webhook_data(mock_pull_request) mock_set_wip.assert_called_once_with(pull_request=mock_pull_request) + @pytest.mark.asyncio + async def test_process_pull_request_webhook_data_edited_action_title_changed( + self, pull_request_handler: PullRequestHandler, mock_pull_request: Mock + ) -> None: + """Test processing pull request webhook data when action is edited and title is changed.""" + pull_request_handler.hook_data["action"] = "edited" + pull_request_handler.hook_data["changes"] = {"title": {"from": "old title"}} + + with patch.object( + pull_request_handler.runner_handler, "run_conventional_title_check" + ) as mock_run_conventional_title_check: + await pull_request_handler.process_pull_request_webhook_data(mock_pull_request) + mock_run_conventional_title_check.assert_called_once_with(pull_request=mock_pull_request) + @pytest.mark.asyncio async def test_process_pull_request_webhook_data_opened_action( self, pull_request_handler: PullRequestHandler, mock_pull_request: Mock