@@ -65,6 +65,32 @@ function Confirm-Requirements {
6565 }
6666}
6767
68+ function Get-RequiredPaths {
69+ param ([string ]$SelectedMode )
70+
71+ $paths = @ (" install/windows.ps1" )
72+ if ($SelectedMode -in @ (" install" , " update" , " test" )) {
73+ $paths += @ (
74+ " bin" ,
75+ " config" ,
76+ " lib" ,
77+ " man" ,
78+ " wordlists" ,
79+ " Gemfile" ,
80+ " Gemfile.lock" ,
81+ " asrfacet-rb.gemspec" ,
82+ " README.md" ,
83+ " LICENSE"
84+ )
85+
86+ if ($SelectedMode -eq " test" ) {
87+ $paths += " spec"
88+ }
89+ }
90+
91+ return $paths
92+ }
93+
6894function Invoke-Step {
6995 param (
7096 [string ]$CommandName ,
@@ -111,11 +137,38 @@ try {
111137 }
112138
113139 $repoDir = Join-Path $WorkDir " source"
114- Invoke-Step - CommandName " Cloning ASRFacet-Rb from GitHub" - Command {
115- & git clone -- depth 1 -- branch $Branch $RepoUrl $repoDir
140+ Invoke-Step - CommandName " Cloning required ASRFacet-Rb files from GitHub" - Command {
141+ & git clone -- depth 1 -- filter = blob:none -- sparse -- branch $Branch $RepoUrl $repoDir
116142 if ($LASTEXITCODE -ne 0 ) {
117143 throw " git clone failed."
118144 }
145+
146+ Push-Location $repoDir
147+ try {
148+ $paths = Get-RequiredPaths - SelectedMode $selectedMode
149+ & git sparse- checkout init -- no- cone
150+ if ($LASTEXITCODE -ne 0 ) {
151+ throw " git sparse-checkout init failed."
152+ }
153+
154+ & git sparse- checkout set -- no- cone @paths
155+ if ($LASTEXITCODE -ne 0 ) {
156+ throw " git sparse-checkout set failed."
157+ }
158+ } catch {
159+ Pop-Location
160+ Write-Warn " Sparse checkout is unavailable in this git environment. Falling back to full shallow clone."
161+ Remove-Item - LiteralPath $repoDir - Recurse - Force - ErrorAction SilentlyContinue
162+ & git clone -- depth 1 -- branch $Branch $RepoUrl $repoDir
163+ if ($LASTEXITCODE -ne 0 ) {
164+ throw " git clone fallback failed."
165+ }
166+ return
167+ } finally {
168+ if ((Get-Location ).Path -eq $repoDir ) {
169+ Pop-Location
170+ }
171+ }
119172 }
120173
121174 $installScript = Join-Path $repoDir " install\windows.ps1"
0 commit comments