Skip to content

Conversation

@MeteorsLiu
Copy link
Collaborator

sparse-checkout set replaces all patterns, causing previously synced module directories to be removed from the working tree. When loading multiple modules into the same formula store, the second sync would erase the first module's files, breaking formula resolution.

Check .git existence to distinguish first-time vs subsequent syncs: first call uses init + set, subsequent calls use add to accumulate patterns. Added TestGitHubClientSyncDirSparseMultiplePaths to cover the multi-directory scenario.

…isting directories

`sparse-checkout set` replaces all patterns, causing previously synced
module directories to be removed from the working tree. When loading
multiple modules into the same formula store, the second sync would
erase the first module's files, breaking formula resolution.

Check .git existence to distinguish first-time vs subsequent syncs:
first call uses init + set, subsequent calls use add to accumulate
patterns. Added TestGitHubClientSyncDirSparseMultiplePaths to cover
the multi-directory scenario.
@gemini-code-assist
Copy link

Summary of Changes

Hello @MeteorsLiu, 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 an issue where git sparse-checkout set would inadvertently remove previously synced module directories when multiple modules were being loaded into the same workspace. The updated logic now intelligently uses sparse-checkout add for subsequent synchronizations, ensuring that existing sparse-checkout patterns are preserved and accumulated. This enhancement significantly improves the reliability and integrity of multi-module synchronization operations.

Highlights

  • Sparse-checkout behavior corrected: Modified the syncDirSparse function to differentiate between initial and subsequent Git sparse-checkout operations. Initial syncs now use sparse-checkout set to define patterns, while subsequent syncs use sparse-checkout add to accumulate patterns, preventing the removal of previously synced directories.
  • Git repository existence check: Implemented a check for the existence of the .git directory within the destination to determine if a repository has already been initialized, guiding the choice between set and add commands for sparse-checkout patterns.
  • New integration test for multiple sparse paths: Added TestGitHubClientSyncDirSparseMultiplePaths to verify that multiple directories can be successfully synced into the same destination using sparse-checkout without overwriting previous syncs, ensuring the fix works as intended.

🧠 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.

Changelog
  • internal/vcs/github.go
    • Introduced a check for an existing .git directory to conditionally initialize the Git repository and sparse-checkout.
    • Switched from sparse-checkout set to sparse-checkout add for subsequent synchronizations to accumulate sparse patterns.
  • internal/vcs/repo_test.go
    • Added TestGitHubClientSyncDirSparseMultiplePaths to validate the correct behavior of sparse-checkout when syncing multiple directories into the same target.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.10%. Comparing base (156cd0e) to head (ef4e457).

Files with missing lines Patch % Lines
internal/vcs/github.go 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   70.24%   72.10%   +1.85%     
==========================================
  Files          26       26              
  Lines        1099     1104       +5     
==========================================
+ Hits          772      796      +24     
+ Misses        259      246      -13     
+ Partials       68       62       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xgopilot
Copy link
Contributor

xgopilot bot commented Feb 11, 2026

Good fix — using sparse-checkout add for subsequent syncs is the correct approach to accumulate patterns without erasing previously synced directories. The test covers the core scenario well.

Two inline suggestions: (1) the gitExists variable naming is misleading since it holds an error, and os.IsNotExist should be used for precision; (2) since the first-sync branch now knows .git doesn't exist, git init/remote add errors can be checked instead of silently discarded.

Copy link

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

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 fixes an issue with sparse-checkout by switching from git sparse-checkout set to git sparse-checkout add for subsequent syncs, preventing overwrites. The security audit could not be completed due to an inability to access the provided files, so no specific vulnerabilities were identified. Additionally, a comment has been provided to improve the robustness of the check for an existing git repository.

Add mock client implementation to enable unit testing without network
calls. Implement comprehensive tests for fileInfo, repo initialization,
and repoFS ReadFile error scenarios.

- Create mockClient type implementing the client interface for testing
- Add mock implementations for Tags, Latest, Stat, ReadFile, and SyncDir
- Test fileInfo struct methods (Name, Size, Mode, ModTime, IsDir, Sys)
- Validate NewRepo error handling for invalid paths
- Test ReadFile error propagation from remote and filesystem

This enables faster, more reliable unit tests by eliminating external
dependencies.
Replace direct error comparison with os.IsNotExist() to properly detect
when the .git directory doesn't exist in syncDirSparse. This fixes the
logic to correctly identify whether to initialize a new git repo (init
branch) or add to an existing one (add branch).

Add test coverage for both branches: one when .git doesn't exist (init)
and one when it does (add), both verifying error handling with cancelled
context.
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