From 85484899c35c84d6c3e90f561308596b522f4019 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 10 Jul 2025 17:26:13 +0530 Subject: [PATCH] fix: implement dedicated method for cleaning PR titles --- pr_agent/tools/pr_description.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 16e5aec8..56391c53 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -168,7 +168,7 @@ class PRDescription: get_logger().debug(f"Labels are the same, not updating") # publish description - pr_title_clean = pr_title.strip().replace('\n', ' ') + pr_title_clean = self.clean_title(pr_title) if get_settings().pr_description.publish_description_as_comment: full_markdown_description = f"## Title\n\n{pr_title_clean}\n\n___\n{pr_body}" if get_settings().pr_description.publish_description_as_comment_persistent: @@ -759,6 +759,12 @@ class PRDescription: """ return pr_body + @staticmethod + def clean_title(title: str) -> str: + """Clean the PR title by stripping whitespace and replacing newlines with spaces.""" + return title.strip().replace('\n', ' ') + + def count_chars_without_html(string): if '<' not in string: return len(string)