Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

final update message in PR description #499

Merged
merged 2 commits into from
Dec 3, 2023
Merged

final update message in PR description #499

merged 2 commits into from
Dec 3, 2023

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Dec 3, 2023

type:

enhancement


description:

This PR introduces several enhancements to the project:

  • A new pr_url attribute has been added to the git providers (codecommit_provider.py, gerrit_provider.py, github_provider.py, gitlab_provider.py). This attribute stores the URL of the pull request.
  • The pr_description.py file has been updated to publish a final update message in the PR description if the final_update_message setting is enabled and the pr_url attribute is present and valid. The message includes a link to the PR description and the latest commit.
  • The configuration.toml file has been updated to include a new setting final_update_message which is set to true by default. This setting controls whether the final update message is published in the PR description.

main_files_walkthrough:

files:
  • pr_agent/git_providers/codecommit_provider.py: Added pr_url attribute to store the URL of the pull request.
  • pr_agent/git_providers/gerrit_provider.py: Added pr_url attribute to store the base URL.
  • pr_agent/git_providers/github_provider.py: Added pr_url attribute to store the URL of the pull request if 'pull' is present in the URL.
  • pr_agent/git_providers/gitlab_provider.py: Added pr_url attribute to store the merge request URL.
  • pr_agent/tools/pr_description.py: Updated to publish a final update message in the PR description if final_update_message setting is enabled and pr_url attribute is present and valid.
  • pr_agent/settings/configuration.toml: Added a new setting final_update_message which is set to true by default. This setting controls whether the final update message is published in the PR description.

Example:

image

Copy link
Contributor

github-actions bot commented Dec 3, 2023

PR Analysis

  • 🎯 Main theme: Adding a pr_url attribute to git providers and a final update message in the PR description.
  • 📝 PR summary: This PR introduces a new attribute, pr_url, to various git providers (CodeCommit, Gerrit, GitHub, GitLab). It also adds a final update message in the PR description, which is linked to the latest commit URL.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2, because the changes are straightforward and do not involve complex logic. However, the changes are spread across multiple files which increases the review effort slightly.
  • 🔒 Security concerns: No

PR Feedback

  • 💡 General suggestions: The changes are clear and well implemented. However, it would be beneficial to add tests to validate the new functionality and ensure that it works as expected across all git providers. Also, consider handling the case where the pr_url is not provided or is invalid.

  • 🤖 Code feedback:
    • relevant file: pr_agent/git_providers/codecommit_provider.py
      suggestion: Consider adding error handling for the case where pr_url is None or invalid. [medium]
      relevant line: self.pr_url = pr_url

    • relevant file: pr_agent/tools/pr_description.py
      suggestion: It would be beneficial to add a check to ensure that the latest_commit_url is not None before publishing the comment. [medium]
      relevant line: if latest_commit_url:

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

@mrT23 mrT23 changed the title feat: Add pr_url attribute to git providers and final update message … Addition of pr_url attribute to git providers and final update message in PR description Dec 3, 2023
@mrT23 mrT23 added the enhancement New feature or request label Dec 3, 2023
@mrT23
Copy link
Collaborator Author

mrT23 commented Dec 3, 2023

PR Description updated to latest commit (586785f)

Copy link
Contributor

github-actions bot commented Dec 3, 2023

PR Code Suggestions

💡 Suggestion:

Consider initializing self.pr_url before self.pr to maintain consistency across all git providers.

File: pr_agent/git_providers/codecommit_provider.py (61-66)

Example code:

Existing code:

self.pr = None
self.diff_files = None
self.git_files = None
self.pr_url = pr_url
if pr_url:
    self.set_pr(pr_url)

Improved code:

self.pr = None
self.diff_files = None
self.git_files = None
self.pr_url = pr_url
if pr_url:
    self.set_pr(pr_url)

💡 Suggestion:

Consider adding a condition to check if base_url is not None before assigning it to self.pr_url to avoid potential issues.

File: pr_agent/git_providers/gerrit_provider.py (192-196)

Example code:

Existing code:

self.repo = Repo(self.repo_path)
assert self.repo
self.pr_url = base_url
self.pr = PullRequestMimic(self.get_pr_title(), self.get_diff_files())

Improved code:

self.repo = Repo(self.repo_path)
assert self.repo
if base_url:
    self.pr_url = base_url
self.pr = PullRequestMimic(self.get_pr_title(), self.get_diff_files())

💡 Suggestion:

Consider adding a comment to explain the purpose of the new code block for better readability.

File: pr_agent/tools/pr_description.py (103-108)

Example code:

Existing code:

if (get_settings().pr_description.final_update_message and
    hasattr(self.git_provider, 'pr_url') and self.git_provider.pr_url):
    latest_commit_url = self.git_provider.get_latest_commit_url()
    if latest_commit_url:
        self.git_provider.publish_comment(
            f"**[PR Description]({self.git_provider.pr_url})** updated to latest commit ({latest_commit_url})")

Improved code:

# If final update message is enabled and the git provider has a PR URL, publish a comment with the PR description and latest commit URL
if (get_settings().pr_description.final_update_message and
    hasattr(self.git_provider, 'pr_url') and self.git_provider.pr_url):
    latest_commit_url = self.git_provider.get_latest_commit_url()
    if latest_commit_url:
        self.git_provider.publish_comment(
            f"**[PR Description]({self.git_provider.pr_url})** updated to latest commit ({latest_commit_url})")

💡 Suggestion:

Consider adding a comment to explain the purpose of the new configuration option final_update_message.

File: pr_agent/settings/configuration.toml (46-49)

Example code:

Existing code:

use_bullet_points=true
extra_instructions = ""
enable_pr_type=true
final_update_message = true

Improved code:

use_bullet_points=true
extra_instructions = ""
enable_pr_type=true
# If set to true, a final update message will be published in the PR description
final_update_message = true

@mrT23 mrT23 changed the title Addition of pr_url attribute to git providers and final update message in PR description final update message in PR description Dec 3, 2023
@mrT23 mrT23 merged commit c9debc3 into main Dec 3, 2023
2 checks passed
@mrT23 mrT23 deleted the tr/describe_message branch December 3, 2023 09:02
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants