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

Add disable_auto_feedback configuration option to control automatic feedback #1379

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Dec 2, 2024

PR Type

enhancement, documentation


Description

  • Introduced a new configuration option disable_auto_feedback to control automatic feedback across multiple platforms.
  • Updated server scripts for Azure DevOps, Bitbucket, GitHub, and GitLab to respect the disable_auto_feedback setting, skipping auto commands if it is enabled.
  • Enhanced documentation to include instructions on disabling automatic feedback and updated configuration examples with toml syntax highlighting.
  • Added the disable_auto_feedback setting to the configuration file with a default value of false.

Changes walkthrough 📝

Relevant files
Enhancement
azuredevops_server_webhook.py
Add configuration check to skip auto commands                       

pr_agent/servers/azuredevops_server_webhook.py

  • Added check for disable_auto_feedback configuration.
  • Skips auto commands if feedback is disabled.
  • +3/-0     
    bitbucket_app.py
    Add configuration check to skip auto commands                       

    pr_agent/servers/bitbucket_app.py

  • Added check for disable_auto_feedback configuration.
  • Skips auto commands if feedback is disabled.
  • +3/-0     
    bitbucket_server_webhook.py
    Add configuration check to skip auto commands                       

    pr_agent/servers/bitbucket_server_webhook.py

  • Added check for disable_auto_feedback configuration.
  • Skips auto commands if feedback is disabled.
  • +5/-0     
    github_app.py
    Add configuration check to skip auto commands                       

    pr_agent/servers/github_app.py

  • Added check for disable_auto_feedback configuration.
  • Skips auto commands if feedback is disabled.
  • +3/-0     
    gitlab_webhook.py
    Add configuration check to skip auto commands                       

    pr_agent/servers/gitlab_webhook.py

  • Added check for disable_auto_feedback configuration.
  • Skips auto commands if feedback is disabled.
  • +3/-0     
    configuration.toml
    Add disable_auto_feedback configuration setting                   

    pr_agent/settings/configuration.toml

    • Added disable_auto_feedback configuration with default value.
    +1/-0     
    Documentation
    automations_and_usage.md
    Document disable_auto_feedback configuration option           

    docs/docs/usage-guide/automations_and_usage.md

  • Documented disable_auto_feedback configuration option.
  • Updated examples with toml syntax highlighting.
  • +27/-14 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 95
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Duplication
    The disable_auto_feedback check logic is duplicated across all server files. Consider extracting this to a shared utility function to improve maintainability.

    Logging Consistency
    The log message format for disabled auto feedback varies slightly between server implementations. Consider standardizing the logging format across all servers.

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Ensure consistent execution order of configuration setup across all server implementations

    Move the apply_repo_settings and is_auto_command setting before the auto feedback
    check to maintain consistent behavior with other server implementations.

    pr_agent/servers/bitbucket_server_webhook.py [74-80]

     if data["eventKey"] == "pr:opened":
         apply_repo_settings(pr_url)
    +    get_settings().set("config.is_auto_command", True)
         if get_settings().config.disable_auto_feedback:  # auto commands for PR, and auto feedback is disabled
             get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {pr_url}", **log_context)
             return
    -    get_settings().set("config.is_auto_command", True)
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Moving the is_auto_command setting before the auto feedback check ensures consistent behavior with other server implementations and maintains better code organization.

    7
    Maintain consistent logging behavior by including context in all log messages

    Include the log context in the log message for consistent logging across the
    codebase.

    pr_agent/servers/github_app.py [377-378]

     if commands_conf == "pr_commands" and get_settings().config.disable_auto_feedback:  # auto commands for PR, and auto feedback is disabled
    -    get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {api_url=}")
    +    get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {api_url=}", **log_context)
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Adding log_context to the log message maintains consistency with other server implementations and provides better debugging capabilities.

    6
    Ensure consistent logging behavior across all server implementations

    Include the log context in the log message and add missing log_context parameter to
    maintain consistent logging.

    pr_agent/servers/bitbucket_app.py [80-81]

     if commands_conf == "pr_commands" and get_settings().config.disable_auto_feedback:  # auto commands for PR, and auto feedback is disabled
    -    get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {api_url=}")
    +    get_logger().info(f"Auto feedback is disabled, skipping auto commands for PR {api_url=}", **log_context)
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Including log_context in the log message aligns with the logging pattern used in other server implementations and improves debugging capabilities.

    6
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    💡 Need additional feedback ? start a PR chat

    @mrT23 mrT23 merged commit 1dd5f0b into main Dec 2, 2024
    2 checks passed
    @mrT23 mrT23 deleted the tr/disable_auto_commands branch December 2, 2024 19:34
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants