From d77a819d92394907fae30577077b64c77a75b3df Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 29 Sep 2024 07:06:48 +0300 Subject: [PATCH 1/3] Add intro text option for PR reviews in configuration and utils --- pr_agent/algo/utils.py | 3 +++ pr_agent/settings/configuration.toml | 1 + 2 files changed, 4 insertions(+) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 08401514..d0a354a1 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -120,6 +120,9 @@ def convert_to_markdown_v2(output_data: dict, if not output_data or not output_data.get('review', {}): return "" + if get_settings().get("pr_reviewer.enable_intro_text", False): + markdown_text += f"Here are some relevant observations to aid the review process:\n\n" + if gfm_supported: markdown_text += "\n" diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 761d6cd5..961fbeb1 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -69,6 +69,7 @@ enable_review_labels_effort=true require_all_thresholds_for_incremental_review=false minimal_commits_for_incremental_review=0 minimal_minutes_for_incremental_review=0 +enable_intro_text=true enable_help_text=false # Determines whether to include help text in the PR review. Enabled by default. # auto approval enable_auto_approval=false From 35b1f5e747e1b085d52e7d923cb9e07dd06ca8c2 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 29 Sep 2024 07:23:34 +0300 Subject: [PATCH 2/3] key --- pr_agent/algo/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index d0a354a1..9e12d8a1 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -121,7 +121,7 @@ def convert_to_markdown_v2(output_data: dict, return "" if get_settings().get("pr_reviewer.enable_intro_text", False): - markdown_text += f"Here are some relevant observations to aid the review process:\n\n" + markdown_text += f"Here are some key observations to aid the review process:\n\n" if gfm_supported: markdown_text += "
\n" From 4a60046f7c8d6ccc2d9c059022c26a55e6bdbd15 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 29 Sep 2024 07:28:02 +0300 Subject: [PATCH 3/3] update tests --- tests/unittest/test_convert_to_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index 5d914203..2eebfdef 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -53,7 +53,7 @@ class TestConvertToMarkdown: 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = f'{PRReviewHeader.REGULAR.value} 🔍\n\n
\n\n\n\n\n
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
⚡ Possible issues: No\n
🔒 No security concerns identified
\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 = f'{PRReviewHeader.REGULAR.value} 🔍\n\nHere are some key observations to aid the review process:\n\n\n\n\n\n\n
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
⚡ Possible issues: No\n
🔒 No security concerns identified
\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_v2(input_data).strip() == expected_output.strip()