From 18472492bc6d776dd320dd03ca4282e9ac524a45 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 26 Feb 2024 09:14:12 +0200 Subject: [PATCH 1/3] s --- pr_agent/algo/utils.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 36ca8a15..c850c7fd 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -51,7 +51,7 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: markdown_text += f"## PR Review\n\n" if gfm_supported: markdown_text += "\n\n" - markdown_text += """""" + markdown_text += """""" if not output_data or not output_data.get('review', {}): return "" @@ -62,7 +62,22 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: key_nice = key.replace('_', ' ').capitalize() emoji = emojis.get(key_nice, "") if gfm_supported: - markdown_text += f"\n" + if 'possible issues' in key_nice.lower(): + value = value.strip() + issues = value.split('\n- ') + number_of_issues = len(issues) + if number_of_issues > 1: + markdown_text += f"\n" + for i, issue in enumerate(issues): + issue = issue.strip('-').strip() + if i == 0: + markdown_text += f"\n" + else: + markdown_text += f"\n\n" + else: + markdown_text += f"\n" + else: + markdown_text += f"\n" else: if len(value.split()) > 1: markdown_text += f"{emoji} **{key_nice}:**\n\n {value}\n\n" From 7c9a389abf1ca1e6677d5f384056f8b90abdc8c0 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 26 Feb 2024 09:27:13 +0200 Subject: [PATCH 2/3] review formatting --- pr_agent/algo/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index c850c7fd..09a6a39b 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -51,7 +51,7 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: markdown_text += f"## PR Review\n\n" if gfm_supported: markdown_text += "
     PR feedback                    
     PR feedback                     
{emoji} {key_nice}\n\n{value}\n\n
{emoji} {key_nice}\n\n{issue}
\n\n{issue}
{emoji} {key_nice}\n\n{value}\n\n
{emoji} {key_nice}\n\n{value}\n\n
\n\n" - markdown_text += """""" + # markdown_text += """""" if not output_data or not output_data.get('review', {}): return "" @@ -62,6 +62,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: key_nice = key.replace('_', ' ').capitalize() emoji = emojis.get(key_nice, "") if gfm_supported: + if 'Estimated effort to review' in key_nice: + key_nice = 'Estimated effort to review [1-5]' if 'possible issues' in key_nice.lower(): value = value.strip() issues = value.split('\n- ') From 85cdf05ca8acbdc7bb21e77adebb54dea6f6539c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 26 Feb 2024 09:36:16 +0200 Subject: [PATCH 3/3] review formatting --- pr_agent/algo/utils.py | 9 +++++---- tests/unittest/test_convert_to_markdown.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 09a6a39b..ef2e5712 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -63,13 +63,13 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: emoji = emojis.get(key_nice, "") if gfm_supported: if 'Estimated effort to review' in key_nice: - key_nice = 'Estimated effort to review [1-5]' + key_nice = 'Estimated effort to review [1-5]' if 'possible issues' in key_nice.lower(): value = value.strip() issues = value.split('\n- ') number_of_issues = len(issues) if number_of_issues > 1: - markdown_text += f"\n" + markdown_text += f"\n" for i, issue in enumerate(issues): issue = issue.strip('-').strip() if i == 0: @@ -77,9 +77,10 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: else: markdown_text += f"\n\n" else: - markdown_text += f"\n" + value = value.strip('-').strip() + markdown_text += f"\n" else: - markdown_text += f"\n" + markdown_text += f"\n" else: if len(value.split()) > 1: markdown_text += f"{emoji} **{key_nice}:**\n\n {value}\n\n" diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index 0b0af128..5337ac6b 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -52,7 +52,7 @@ class TestConvertToMarkdown: 'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n", 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = '## PR Review\n\n
     PR feedback                     
      Feedback            
{emoji} {key_nice}
{emoji} {key_nice}
\n\n{issue}
{emoji} {key_nice}\n\n{value}\n\n
{emoji} {key_nice}\n\n{value}\n\n
{emoji} {key_nice}\n\n{value}\n\n
{emoji} {key_nice}\n\n{value}\n\n
\n\n\n\n\n\n
     PR feedback                    
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' + expected_output = '## PR Review\n\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' assert convert_to_markdown(input_data).strip() == expected_output.strip()