Ensure .git folder exists to prevent Windows Search indexing of entire scoop folder#6601
Ensure .git folder exists to prevent Windows Search indexing of entire scoop folder#660129039 wants to merge 1 commit intoScoopInstaller:masterfrom
Conversation
WalkthroughA startup operation has been added to ensure the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/core.ps1`:
- Around line 1313-1314: Remove the call that creates a fake .git folder (the
ensure "$scoopdir\.git" | Out-Null line) because it breaks Git bucket
operations; instead, stop creating $scoopdir\.git and replace it with a non-Git
approach such as invoking a new helper (e.g., Add-DirectoryToSearchExclusion or
Set-DesktopIniExclusion) with $scoopdir as the argument to add $scoopdir to
Windows Search exclusions or apply a desktop.ini-based exclusion; update any
callers or documentation to reference the new helper and ensure the ensure
function is no longer used to create $scoopdir\.git.
| # Ensure .git folder exists to prevent Windows Search indexing | ||
| ensure "$scoopdir\.git" | Out-Null |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the overall structure and find PowerShell files
ls -la lib/ | head -20Repository: ScoopInstaller/Scoop
Length of output: 1262
🏁 Script executed:
# Search for git operations in scoop's PowerShell files
rg -n 'Invoke-Git|\.git|git ' lib/ --type=ps1 -A 2 -B 2 | head -100Repository: ScoopInstaller/Scoop
Length of output: 91
🏁 Script executed:
# Check for bucket-related code and git operations
rg -n 'bucketsdir|buckets|bucket' lib/ --type=ps1 | head -50Repository: ScoopInstaller/Scoop
Length of output: 91
🏁 Script executed:
# Look at the ensure function definition
sed -n '599,604p' lib/core.ps1Repository: ScoopInstaller/Scoop
Length of output: 222
🏁 Script executed:
# Check the context around the new code (lines 1310-1320)
sed -n '1310,1320p' lib/core.ps1Repository: ScoopInstaller/Scoop
Length of output: 245
🏁 Script executed:
# Search for git operations in all files in lib/
grep -rn 'Invoke-Git\|git ' lib/*.ps1 | head -50Repository: ScoopInstaller/Scoop
Length of output: 1954
🏁 Script executed:
# Look at buckets.ps1 to understand bucket structure
cat lib/buckets.ps1Repository: ScoopInstaller/Scoop
Length of output: 7452
🏁 Script executed:
# Search for where buckets directory is used
grep -n 'bucketsdir\|\$buckets' lib/*.ps1Repository: ScoopInstaller/Scoop
Length of output: 866
🏁 Script executed:
# Check if scoop itself is a git repo and how it's structured
head -20 lib/core.ps1 | grep -i gitRepository: ScoopInstaller/Scoop
Length of output: 46
🏁 Script executed:
# Look for any existing git directory handling
grep -rn '\.git' lib/*.ps1Repository: ScoopInstaller/Scoop
Length of output: 1447
🏁 Script executed:
# Look at the Invoke-Git function
sed -n '219,260p' lib/core.ps1Repository: ScoopInstaller/Scoop
Length of output: 1328
🏁 Script executed:
# Confirm the git directory structure in buckets
grep -n 'Test-Path.*\.git' lib/buckets.ps1Repository: ScoopInstaller/Scoop
Length of output: 235
Creating a fake .git directory will break scoop's bucket git operations.
Scoop stores buckets as git repositories under $scoopdir\buckets\<name>\.git and executes git commands directly in these directories (e.g., git config remote.origin.url, git log). When git runs in any bucket directory, it walks up the directory tree to find the repository root. A fake .git at $scoopdir (the parent directory) will be discovered first, causing git to misidentify the repository root and breaking bucket operations. Additionally, git-aware tools (VS Code, IDEs, etc.) will detect this fake .git as a corrupted repository.
Consider these alternatives to exclude the scoop directory from Windows Search:
- Add
$scoopdirto the Windows Search exclusion list programmatically (via registry or COM) - Use Windows desktop.ini with appropriate attributes
- If
.gitis necessary, test thoroughly before deployment as it will directly impact bucket management
🧰 Tools
🪛 PSScriptAnalyzer (1.23.0)
[warning] Missing BOM encoding for non-ASCII encoded file 'core.ps1'
(PSUseBOMForUnicodeEncodedFile)
🤖 Prompt for AI Agents
In `@lib/core.ps1` around lines 1313 - 1314, Remove the call that creates a fake
.git folder (the ensure "$scoopdir\.git" | Out-Null line) because it breaks Git
bucket operations; instead, stop creating $scoopdir\.git and replace it with a
non-Git approach such as invoking a new helper (e.g.,
Add-DirectoryToSearchExclusion or Set-DesktopIniExclusion) with $scoopdir as the
argument to add $scoopdir to Windows Search exclusions or apply a
desktop.ini-based exclusion; update any callers or documentation to reference
the new helper and ensure the ensure function is no longer used to create
$scoopdir\.git.
Description
Fun fact that Windows search will automatically ignore and folder and subfolders if that folder has a folder called .git in it.
https://learn.microsoft.com/en-us/answers/questions/3790317/search-index-excludes-any-folder-with-a-git-subfol
This puts a .git folder in place to trick the Windows search into not indexing the whole scoop folder which contains heaps of program files which get in the way of searching for real documents, since scoop by default lives under the user profile this is usually indexed.
Motivation and Context
It was really annoying.
How Has This Been Tested?
Yep
Checklist:
developbranch.Summary by CodeRabbit