Merge remote-tracking branch 'origin/main' into tr/unique_titles

This commit is contained in:
mrT23
2024-01-08 10:30:58 +02:00
8 changed files with 198 additions and 22 deletions

View File

@ -75,15 +75,18 @@ class GitProvider(ABC):
def get_user_description(self) -> str:
description = (self.get_pr_description_full() or "").strip()
description_lowercase = description.lower()
get_logger().info(f"Existing description:\n{description_lowercase}")
# if the existing description wasn't generated by the pr-agent, just return it as-is
if not self._is_generated_by_pr_agent(description_lowercase):
get_logger().info(f"Existing description was not generated by the pr-agent")
return description
# if the existing description was generated by the pr-agent, but it doesn't contain a user description,
# return nothing (empty string) because it means there is no user description
user_description_header = "## **user description**"
if user_description_header not in description_lowercase:
get_logger().info(f"Existing description was generated by the pr-agent, but it doesn't contain a user description")
return ""
# otherwise, extract the original user description from the existing pr-agent description and return it
@ -106,6 +109,7 @@ class GitProvider(ABC):
if original_user_description.lower().startswith(user_description_header):
original_user_description = original_user_description[len(user_description_header):].strip()
get_logger().info(f"Extracted user description from existing description:\n{original_user_description}")
return original_user_description
def _possible_headers(self):