Added comments explaining the logic behind get_user_description

This commit is contained in:
zmeir
2023-08-22 10:04:21 +03:00
parent 2b22f712fb
commit 09ef809080

View File

@ -96,10 +96,14 @@ class GitProvider(ABC):
def get_user_description(self) -> str:
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 not description.startswith("## PR Type"):
return 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
if "## User Description:" not in description:
return ""
# otherwise, extract the original user description from the existing pr-agent description and return it
return description.split("## User Description:", 1)[1].strip()
@abstractmethod