From 09ef809080cd72051734d3fe94313efc71b272c1 Mon Sep 17 00:00:00 2001 From: zmeir Date: Tue, 22 Aug 2023 10:04:21 +0300 Subject: [PATCH] Added comments explaining the logic behind `get_user_description` --- pr_agent/git_providers/git_provider.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 9db0a5bd..0837155c 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -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