Skip to content

Commit

Permalink
Use ReviewHeaderTitle in lieu of PrReviewTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
KennyDizi committed Jun 27, 2024
1 parent ba96314 commit 692904b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ModelType(str, Enum):
REGULAR = "regular"
TURBO = "turbo"

class PrReviewTitle(str, Enum):
class ReviewHeaderTitle(str, Enum):
REGULAR = "## PR Reviewer Guide"
INCREMENTAL = "## Incremental PR Reviewer Guide"

Expand Down Expand Up @@ -90,9 +90,9 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment
}
markdown_text = ""
if not incremental_review:
markdown_text += f"{PrReviewTitle.REGULAR.value} 🔍\n\n"
markdown_text += f"{ReviewHeaderTitle.REGULAR.value} 🔍\n\n"
else:
markdown_text += f"{PrReviewTitle.INCREMENTAL.value} 🔍\n\n"
markdown_text += f"{ReviewHeaderTitle.INCREMENTAL.value} 🔍\n\n"
markdown_text += f"⏮️ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
if gfm_supported:
markdown_text += "<table>\n"
Expand Down
6 changes: 3 additions & 3 deletions pr_agent/git_providers/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from ..algo.file_filter import filter_ignored
from ..algo.language_handler import is_valid_file
from ..algo.utils import PrReviewTitle, load_large_diff, clip_tokens, find_line_number_of_relevant_line_in_file
from ..algo.utils import ReviewHeaderTitle, load_large_diff, clip_tokens, find_line_number_of_relevant_line_in_file
from ..config_loader import get_settings
from ..log import get_logger
from ..servers.utils import RateLimitExceeded
Expand Down Expand Up @@ -96,9 +96,9 @@ def get_previous_review(self, *, full: bool, incremental: bool):
self.comments = list(self.pr.get_issue_comments())
prefixes = []
if full:
prefixes.append({PrReviewTitle.REGULAR.value})
prefixes.append({ReviewHeaderTitle.REGULAR.value})
if incremental:
prefixes.append({PrReviewTitle.INCREMENTAL.value})
prefixes.append({ReviewHeaderTitle.INCREMENTAL.value})
for index in range(len(self.comments) - 1, -1, -1):
if any(self.comments[index].body.startswith(prefix) for prefix in prefixes):
return self.comments[index]
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/tools/pr_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler
from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import PrReviewTitle, convert_to_markdown, github_action_output, load_yaml, ModelType, \
from pr_agent.algo.utils import ReviewHeaderTitle, convert_to_markdown, github_action_output, load_yaml, ModelType, \
show_relevant_configurations
from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider, get_git_provider_with_context
Expand Down Expand Up @@ -134,7 +134,7 @@ async def run(self) -> None:
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
final_update_message = get_settings().pr_reviewer.final_update_message
self.git_provider.publish_persistent_comment(pr_review,
initial_header=f"{PrReviewTitle.REGULAR.value} 🔍",
initial_header=f"{ReviewHeaderTitle.REGULAR.value} 🔍",
update_header=True,
final_update_message=final_update_message, )
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/unittest/test_convert_to_markdown.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by CodiumAI
from pr_agent.algo.utils import PrReviewTitle, convert_to_markdown
from pr_agent.algo.utils import ReviewHeaderTitle, convert_to_markdown
from pr_agent.tools.pr_description import insert_br_after_x_chars

"""
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_simple_dictionary_input(self):
'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 = f'{PrReviewTitle.REGULAR.value} 🔍\n\n<table>\n<tr><td> ⏱️&nbsp;<strong>Estimated&nbsp;effort&nbsp;to&nbsp;review [1-5]</strong></td><td>\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n</td></tr>\n<tr><td> 🧪&nbsp;<strong>Relevant tests</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> ⚡&nbsp;<strong>Possible issues</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> 🔒&nbsp;<strong>Security concerns</strong></td><td>\nNo\n\n</td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>\n\n<strong>\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</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'
expected_output = f'{ReviewHeaderTitle.REGULAR.value} 🔍\n\n<table>\n<tr><td> ⏱️&nbsp;<strong>Estimated&nbsp;effort&nbsp;to&nbsp;review [1-5]</strong></td><td>\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n</td></tr>\n<tr><td> 🧪&nbsp;<strong>Relevant tests</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> ⚡&nbsp;<strong>Possible issues</strong></td><td>\nNo\n\n\n</td></tr>\n<tr><td> 🔒&nbsp;<strong>Security concerns</strong></td><td>\nNo\n\n</td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>\n\n<strong>\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</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'

assert convert_to_markdown(input_data).strip() == expected_output.strip()

Expand Down

0 comments on commit 692904b

Please sign in to comment.