mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 13:20:39 +08:00
Fix get_user_description
The headers changed from "PR Type"/"PR Description"/etc to "Type"/"Description"/etc
This commit is contained in:
@ -75,14 +75,18 @@ class GitProvider(ABC):
|
|||||||
def get_user_description(self) -> str:
|
def get_user_description(self) -> str:
|
||||||
description = (self.get_pr_description_full() or "").strip()
|
description = (self.get_pr_description_full() or "").strip()
|
||||||
# if the existing description wasn't generated by the pr-agent, just return it as-is
|
# if the existing description wasn't generated by the pr-agent, just return it as-is
|
||||||
if not any(description.startswith(header) for header in ("## PR Type", "## PR Description")):
|
if not self._is_generated_by_pr_agent(description):
|
||||||
return description
|
return description
|
||||||
# if the existing description was generated by the pr-agent, but it doesn't contain the user description,
|
# if the existing description was generated by the pr-agent, but it doesn't contain the user description,
|
||||||
# return nothing (empty string) because it means there is no user description
|
# return nothing (empty string) because it means there is no user description
|
||||||
if "## User Description:" not in description:
|
if "## User Description" not in description:
|
||||||
return ""
|
return ""
|
||||||
# otherwise, extract the original user description from the existing pr-agent description and return it
|
# otherwise, extract the original user description from the existing pr-agent description and return it
|
||||||
return description.split("## User Description:", 1)[1].strip()
|
return description.split("## User Description", 1)[-1].split("\n", 1)[-1].strip()
|
||||||
|
|
||||||
|
def _is_generated_by_pr_agent(self, description: str) -> bool:
|
||||||
|
possible_headers = ("## PR Type", "## PR Description", "## PR Labels", "## Type", "## Description", "## Labels", "### 🤖 Generated by PR Agent")
|
||||||
|
return any(description.startswith(header) for header in possible_headers)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_repo_settings(self):
|
def get_repo_settings(self):
|
||||||
|
@ -297,7 +297,7 @@ class PRDescription:
|
|||||||
value = self.file_label_dict
|
value = self.file_label_dict
|
||||||
key_publish = "PR changes walkthrough"
|
key_publish = "PR changes walkthrough"
|
||||||
else:
|
else:
|
||||||
key_publish = key.rstrip(':').replace("_", " ").capitalize()
|
key_publish = key.rstrip(':').replace("_", " ").title()
|
||||||
pr_body += f"## {key_publish}\n"
|
pr_body += f"## {key_publish}\n"
|
||||||
if 'walkthrough' in key.lower():
|
if 'walkthrough' in key.lower():
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
Reference in New Issue
Block a user