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

Fix duplicate comment for github #191

Merged
merged 3 commits into from
Oct 13, 2024
Merged

Fix duplicate comment for github #191

merged 3 commits into from
Oct 13, 2024

Conversation

tapishr
Copy link
Member

@tapishr tapishr commented Oct 13, 2024

Please check the action items covered in the PR -

  • Build is running
  • Eventing is functional and tested
  • Unit or integration tests added and running
  • Manual QA

Summary by CodeRabbit

  • New Features

    • Enhanced comment insertion logic based on relevance changes for improved accuracy.
    • Updated review processing to handle both current and previous review states in GitHub reviews.
  • Bug Fixes

    • Improved logging clarity for comment insertion and review processing.
  • Refactor

    • Streamlined the flow of comment and review creation processes for better maintainability.
    • Updated the review creation function to return both current and previous review objects.
  • Chores

    • Incremented package version from 2.0.2 to 2.0.3.

Copy link
Contributor

coderabbitai bot commented Oct 13, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve modifications to the process_relevance and process_review functionalities within the relevance.rs and review.rs files, respectively. In relevance.rs, the logic for comment creation and insertion is reordered to first check if a comment needs to change before creating it. In review.rs, the return type of the create_and_save_github_review_object function is updated to return a tuple, allowing it to provide both the new and optional previous review objects. Logging statements in both files have been adjusted for clarity.

Changes

File Path Change Summary
vibi-dpu/src/core/relevance.rs Reordered logic in process_relevance to check for comment changes before creation. Adjusted logging for clarity. Consolidated comment insertion logic for Bitbucket and GitHub.
vibi-dpu/src/core/review.rs Updated return type of create_and_save_github_review_object from Option<Review> to (Option<Review>, Option<Review>). Adjusted parse_review to handle new return type and updated logging statements.
vibi-dpu/Cargo.toml Incremented package version from 2.0.2 to 2.0.3. No other changes to dependencies or metadata.

Poem

In the code where rabbits hop,
Comments now won't just plop!
Check first if they need to change,
Then create, it's not so strange!
Reviews now track both old and new,
Hopping through logic, swift and true! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vibinex-dpu bot commented Oct 13, 2024

Relevant users for this PR:

Contributor Name/Alias Relevance
tapishr 66.67%
MuskanPaliwal 33.33%

Auto assigning to relevant reviewers.

If you are a relevant reviewer, you can use the Vibinex browser extension to see parts of the PR relevant to you
Relevance of the reviewer is calculated based on the git blame information of the PR. To know more, hit us up at contact@vibinex.com.

To change comment and auto-assign settings, go to your Vibinex settings page.

Copy link

vibinex-dpu bot commented Oct 13, 2024

Diff Graph:

Call Stack Diff

%%{init: { 'theme': 'neutral', 'themeVariables': { 'fontSize': '20px' }, 'flowchart': { 'nodeSpacing': 100, 'rankSpacing': 100 } } }%%
 	flowchart LR

	classDef modified stroke:black,fill:yellow
	classDef added stroke:black,fill:#b7e892,color:black
	classDef deleted stroke:black,fill:red

Loading

To modify DiffGraph settings, go to your Vibinex settings page.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 44d25f4 and c9be068.

📒 Files selected for processing (2)
  • vibi-dpu/src/core/relevance.rs (1 hunks)
  • vibi-dpu/src/core/review.rs (3 hunks)
🧰 Additional context used
🔇 Additional comments (7)
vibi-dpu/src/core/review.rs (4)

148-148: LGTM: Improved handling of review objects

This change directly captures both the new and old review objects from create_and_save_github_review_object. It aligns with the updated function signature and improves code clarity by eliminating the need for separate handling of the old review.


227-227: LGTM: Enhanced function signature for better review handling

The updated function signature now returns a tuple of (Option<Review>, Option<Review>). This change allows the function to return both the new and old review objects, providing more comprehensive information about the review state. It aligns well with the modifications in the parse_review function and improves the overall review handling process.


232-233: LGTM: Improved review object handling and error management

The changes in this function enhance the review object handling process:

  1. The pr_id is now correctly extracted from the JSON data.
  2. Error handling has been improved to return both None and old_review_opt, ensuring that the old review information is not lost even if creating a new review fails.
  3. The function now correctly returns both the new and old review objects, aligning with the updated function signature.

These modifications improve the robustness and consistency of the review handling process.

Also applies to: 237-237, 255-255


Line range hint 148-255: Summary: Effective improvements in review object handling

The changes in this file consistently enhance the review processing functionality:

  1. The parse_review function now directly captures both new and old review objects.
  2. The create_and_save_github_review_object function has been updated to return both new and old review objects.
  3. Error handling has been improved to ensure old review information is preserved even in failure scenarios.

These modifications result in more robust and comprehensive review handling, improving the overall functionality of the review system.

vibi-dpu/src/core/relevance.rs (3)

24-36: Improved efficiency and clarity in comment handling

The reordering of the comment creation and insertion logic is a good improvement. By first checking if the comment needs to change using did_comment_change, unnecessary operations are avoided. This change enhances both efficiency and readability.

The consolidation of logic for Bitbucket and GitHub, along with the updated logging messages, improves the overall structure and clarity of the code.


34-35: Enhanced logging for GitHub comment insertion

The addition of the logging statement for GitHub comment insertion is a good improvement. It provides consistency with the Bitbucket logging and enhances the traceability of the comment insertion process across different platforms.


Line range hint 1-38: Overall improvements with a minor issue

The changes in this file significantly improve the efficiency and clarity of the comment handling process in the process_relevance function. The reordering of logic and additional logging statements enhance both the performance and traceability of the code.

However, there's a minor indentation issue on line 35 that should be addressed. Once this is fixed, the changes will be fully aligned with best practices and the PR objectives.

Please make the suggested indentation correction, and the changes will be ready for approval.

vibi-dpu/src/core/relevance.rs Show resolved Hide resolved
Copy link

vibinex-dpu bot commented Oct 13, 2024

Relevant users for this PR:

Contributor Name/Alias Relevance
tapishr 69.23%
MuskanPaliwal 30.77%

Auto assigning to relevant reviewers.

If you are a relevant reviewer, you can use the Vibinex browser extension to see parts of the PR relevant to you
Relevance of the reviewer is calculated based on the git blame information of the PR. To know more, hit us up at contact@vibinex.com.

To change comment and auto-assign settings, go to your Vibinex settings page.

Copy link

Copy link

vibinex-dpu bot commented Oct 13, 2024

Diff Graph:

Call Stack Diff

%%{init: { 'theme': 'neutral', 'themeVariables': { 'fontSize': '20px' }, 'flowchart': { 'nodeSpacing': 100, 'rankSpacing': 100 } } }%%
 	flowchart LR

	classDef modified stroke:black,fill:yellow
	classDef added stroke:black,fill:#b7e892,color:black
	classDef deleted stroke:black,fill:red

Loading

To modify DiffGraph settings, go to your Vibinex settings page.

@tapishr tapishr merged commit 2ffdd2b into main Oct 13, 2024
2 checks passed
@tapishr tapishr deleted the tr/duplicate/comment branch October 13, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant