Skip to content

fix(pm): validate directory - #2465

Merged
elrrrrrrr merged 2 commits into
nextfrom
fix-validate
Dec 29, 2025
Merged

fix(pm): validate directory#2465
elrrrrrrr merged 2 commits into
nextfrom
fix-validate

Conversation

@elrrrrrrr

Copy link
Copy Markdown
Contributor
  • 🐞 Fix issue where file contents unchanged but version changes during reinstallation.

https://github.com/ant-design/ant-design/pull/56382/changes

@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Dec 29, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the package manager where reinstallation could lead to inconsistent package versions, even if the underlying file contents were unchanged. The core of the fix involves enhancing the package cloning process with explicit validation of the package's name and version from its package.json file. This ensures that only correctly versioned packages are retained, preventing unexpected version changes and improving the overall reliability and integrity of package installations.

Highlights

  • New Package Validation Logic: Introduced a validate_name_version function to explicitly check the name and version within a package's package.json file at the destination path.
  • Smart Package Cloning: Implemented a new clone_package function that intelligently handles package installations: it skips cloning if a valid package already exists, removes and re-clones if a version or name mismatch is detected, and performs a fresh clone if the destination is empty.
  • Refactored Cloning Calls: Updated all existing calls to the cloning utility across the package manager to utilize the new clone_package function, ensuring that package name and version are passed for proper validation.
  • Comprehensive Testing: Added a suite of unit tests for the new validate_name_version and clone_package functions, covering various scenarios including matching, mismatched names/versions, missing package.json, and fresh installations, to ensure the robustness of the fix.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a validation step before cloning a package to fix an issue where a package would not be updated if only its version changed. The new clone_package function correctly checks the package.json for name and version mismatches and forces a re-clone if necessary. The changes are well-implemented and include comprehensive tests for the new logic. I've suggested a small refactoring to improve code clarity and reduce duplication in the clone_package function. Additionally, the change from .as_ref() to .clone() when handling the package version is a crucial fix to prevent potential lifetime issues with spawned async tasks.

Comment thread crates/pm/src/util/cloner.rs
@elrrrrrrr
elrrrrrrr merged commit f26995d into next Dec 29, 2025
21 checks passed
@elrrrrrrr
elrrrrrrr deleted the fix-validate branch December 29, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants