Added PRHelpMessage to command execution in pr_agent.py

This commit is contained in:
mrT23
2024-02-18 13:06:57 +02:00
parent e9382b18b6
commit ed5856493c

View File

@ -8,38 +8,34 @@ class PRHelpMessage:
The PRConfig class is responsible for listing all configuration options available for the user. The PRConfig class is responsible for listing all configuration options available for the user.
""" """
def __init__(self, pr_url: str, args=None, ai_handler=None): def __init__(self, pr_url: str, args=None, ai_handler=None):
"""
Initialize the PRConfig object with the necessary attributes and objects to comment on a pull request.
Args:
pr_url (str): The URL of the pull request to be reviewed.
args (list, optional): List of arguments passed to the PRReviewer class. Defaults to None.
"""
self.git_provider = get_git_provider()(pr_url) self.git_provider = get_git_provider()(pr_url)
async def run(self): async def run(self):
get_logger().info('Getting PR Help Message...') try:
pr_comment="## PR Agent Intro\n\n" get_logger().info('Getting PR Help Message...')
pr_comment +="🤖 Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.""" pr_comment="## PR Agent Intro\n\n"
pr_comment +="\n\nHere are the tools you can use to interact with the PR Agent:\n" pr_comment +="🤖 Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more."""
base_path ="https://github.com/Codium-ai/pr-agent/tree/main/docs" pr_comment +="\n\nHere are the tools you can use to interact with the PR Agent:\n"
pr_comment +=f""" base_path ="https://github.com/Codium-ai/pr-agent/tree/main/docs"
\n\n pr_comment +=f"""
- [DESCRIBE]({base_path}/DESCRIBE.md) \n\n
- [REVIEW]({base_path}/REVIEW.md) - [DESCRIBE]({base_path}/DESCRIBE.md)
- [IMPROVE](./IMPROVE.md) - [REVIEW]({base_path}/REVIEW.md)
- [ASK]({base_path}/ASK.md) - [IMPROVE]({base_path}/IMPROVE.md)
- [SIMILAR_ISSUE]({base_path}/SIMILAR_ISSUE.md) - [ASK]({base_path}/ASK.md)
- [UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md) - [SIMILAR_ISSUE]({base_path}/SIMILAR_ISSUE.md)
- [ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md) - [UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md)
- [GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md) - [ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md)
- [Analyze]({base_path}/Analyze.md) - [GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md)
- [Test]({base_path}/TEST.md) - [Analyze]({base_path}/Analyze.md)
- [CI Feedback]({base_path}/CI_FEEDBACK.md) - [Test]({base_path}/TEST.md)
""" - [CI Feedback]({base_path}/CI_FEEDBACK.md)
pr_comment +=f"""\n\nNote that each command be [applied automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-pr-actions) when a new PR is opened, or invoked manually by [commenting on a PR](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#online-usage).""" """
if get_settings().config.publish_output: pr_comment +=f"""\n\nNote that each command be [applied automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-pr-actions) when a new PR is opened, or invoked manually by [commenting on a PR](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#online-usage)."""
self.git_provider.publish_comment(pr_comment) if get_settings().config.publish_output:
self.git_provider.publish_comment(pr_comment)
except Exception as e:
get_logger().error(f"Error while running PRHelpMessage: {e}")
return "" return ""
def _prepare_pr_configs(self) -> str: def _prepare_pr_configs(self) -> str: