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

Adding get_pr_id method to Git Providers #320

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Adding get_pr_id method to Git Providers #320

merged 2 commits into from
Sep 21, 2023

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Sep 21, 2023

PR Type:

Enhancement


PR Description:

This PR introduces a new method, get_pr_id, in the abstract Git Provider class and its implementations (GitHub and GitLab). The method is designed to return the PR ID, which is used in the PR Description tool. This change provides a more consistent and error-tolerant way of fetching the PR ID across different Git providers.


PR Main Files Walkthrough:

files:

pr_agent/git_providers/git_provider.py: Added the abstract method get_pr_id to the abstract Git Provider class.
pr_agent/git_providers/github_provider.py: Implemented the get_pr_id method for the GitHub provider, which returns the PR ID in the format "repo/pr_num".
pr_agent/git_providers/gitlab_provider.py: Implemented the get_pr_id method for the GitLab provider, which returns the PR ID as the web URL of the merge request.
pr_agent/tools/pr_description.py: Replaced the direct assignment of pr_id with a call to the new get_pr_id method from the Git Provider.

@mrT23
Copy link
Collaborator Author

mrT23 commented Sep 21, 2023

/describe

@github-actions
Copy link
Contributor

PR Analysis

  • 🎯 Main theme: Adding a method to get PR id in different git providers
  • 📝 PR summary: The PR introduces a new method 'get_pr_id' in the abstract class 'git_provider' and implements it in the derived classes 'github_provider' and 'gitlab_provider'. This method is then used in 'pr_description.py' to get the PR id.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2
    The PR is small and straightforward, with the addition of a new method in a few classes. However, the lack of tests and error handling in the new method could require some time to review.
  • 🔒 Security concerns: No
    The PR does not seem to introduce any security concerns. It only adds a new method for getting the PR id, which does not involve any sensitive operations.

PR Feedback

  • 💡 General suggestions: The new method 'get_pr_id' could benefit from better error handling. Currently, it just returns an empty string in case of an exception, which might not be informative enough for the caller. Consider raising a custom exception or at least logging the error message.

  • 🤖 Code feedback:

    • relevant file: pr_agent/git_providers/github_provider.py
      suggestion: Consider adding specific exceptions in the except block instead of catching all exceptions. This would make it easier to understand and handle the potential errors. [important]
      relevant line: except:

    • relevant file: pr_agent/git_providers/gitlab_provider.py
      suggestion: Similar to the previous suggestion, consider specifying the exceptions that you are trying to catch. [important]
      relevant line: except:

    • relevant file: pr_agent/git_providers/git_provider.py
      suggestion: Consider adding a docstring to the new method 'get_pr_id' to explain its purpose and return value. [medium]
      relevant line: def get_pr_id(self):

How to use

To invoke the PR-Agent, add a comment using one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest improvements to the code in the PR. Extended mode employs several calls, and provides a more thorough feedback.
/ask <QUESTION>: Pose a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.

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

@github-actions github-actions bot changed the title Tr/pr Implementing get_pr_id method in Git Providers Sep 21, 2023
@github-actions github-actions bot added the enhancement New feature or request label Sep 21, 2023
@mrT23 mrT23 changed the title Implementing get_pr_id method in Git Providers Adding get_pr_id method to Git Providers Sep 21, 2023
@mrT23 mrT23 merged commit d384b06 into main Sep 21, 2023
3 checks passed
@mrT23 mrT23 deleted the tr/pr_id branch September 21, 2023 18:38
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Implementing get_pr_id method in Git Providers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant