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

Preserve User-Added Labels in Pull Requests #433

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Conversation

hussam789
Copy link
Collaborator

@hussam789 hussam789 commented Nov 6, 2023

PR Type:

Enhancement


PR Description:

This PR introduces a feature to preserve user-added labels in pull requests. The main changes include:

  • A new function get_user_labels has been added in pr_agent/algo/utils.py to filter out labels added by the user.
  • The run methods in pr_agent/tools/pr_description.py and pr_agent/tools/pr_generate_labels.py have been updated to use get_user_labels function to keep user-added labels.
  • Minor changes in pr_agent/settings/pr_description_prompts.toml to accommodate the new changes.

PR Main Files Walkthrough:

files:
  • pr_agent/algo/utils.py: Added a new function get_user_labels to filter out labels added by the user.
  • pr_agent/tools/pr_description.py: Updated the run method to use get_user_labels function to keep user-added labels when publishing the PR description.
  • pr_agent/tools/pr_generate_labels.py: Updated the run method to use get_user_labels function to keep user-added labels when generating PR labels.
  • pr_agent/settings/pr_description_prompts.toml: Minor changes to accommodate the new changes related to user labels.

@hussam789 hussam789 requested a review from mrT23 November 6, 2023 13:14
Copy link
Contributor

github-actions bot commented Nov 6, 2023

PR Analysis

  • 🎯 Main theme: The PR focuses on preserving user-added labels in the PR.
  • 📝 PR summary: The PR introduces a new function get_user_labels that filters out system labels and only keeps user-added labels. This function is then used in pr_description.py and pr_generate_labels.py to ensure that user labels are preserved when publishing labels.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2, the PR is relatively small and the changes are straightforward. However, the lack of tests and description increases the review effort slightly.
  • 🔒 Security concerns: No

PR Feedback

  • 💡 General suggestions: The PR seems to be well-structured and the changes are clear. However, it would be beneficial to include a description in the PR to provide context and reasoning for the changes. Additionally, adding tests to verify the new functionality would be beneficial.

  • 🤖 Code feedback:

    • relevant file: pr_agent/algo/utils.py
      suggestion: Consider handling the case where current_labels is not a list. This could potentially lead to a TypeError when trying to iterate over current_labels in the get_user_labels function. [important]
      relevant line: def get_user_labels(current_labels):

    • relevant file: pr_agent/algo/utils.py
      suggestion: It might be more efficient to convert current_labels to a set before the loop in get_user_labels function, as checking membership in a set is faster than in a list. [medium]
      relevant line: for label in current_labels:

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.

@hussam789 hussam789 merged commit ef9af26 into main Nov 6, 2023
3 checks passed
@hussam789 hussam789 deleted the hl/user_labels branch November 6, 2023 13:17
@mrT23
Copy link
Collaborator

mrT23 commented Nov 6, 2023

PR Analysis

  • 🎯 Main theme: The PR introduces a new feature to keep user-added labels in the PR, while adding or updating other labels.
  • 📝 PR summary: The PR modifies the label handling logic in the PR agent. It introduces a new function get_user_labels that filters out user-added labels from the current labels. These user labels are then kept while other labels are added or updated.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2, because the PR is relatively small and the changes are straightforward. However, the lack of tests and the potential impact on the label handling logic requires careful review.
  • 🔒 Security concerns: No

PR Feedback

  • 💡 General suggestions: The PR is generally well-written and the changes are clear. However, it would be beneficial to add tests for the new feature to ensure it works as expected and does not introduce any regressions. Additionally, consider handling the case where get_settings().config.enable_custom_labels is False but label is in get_settings().custom_labels.

  • 🤖 Code feedback:

    • relevant file: pr_agent/algo/utils.py
      suggestion: Consider handling the case where get_settings().config.enable_custom_labels is False but label is in get_settings().custom_labels. This could potentially lead to unexpected behavior. [important]
      relevant line: if get_settings().config.enable_custom_labels:

    • relevant file: pr_agent/algo/utils.py
      suggestion: Consider adding a debug log statement when no user labels are found. This could help in debugging issues related to label handling. [medium]
      relevant line: if user_labels:

@mrT23 mrT23 changed the title Keep user labels Preserve User-Added Labels in Pull Requests Nov 6, 2023
@mrT23 mrT23 added the enhancement New feature or request label Nov 6, 2023
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
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants