From 096e3c74c10e730453ac472558a53e8835c0c8bc Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Wed, 27 May 2026 22:16:38 +0900 Subject: [PATCH] Clean up partial clone before falling back to full clone `RBS::Collection::Sources::Git#setup!` retries with a non-filtered `git clone` when the `--filter=blob:none` variant fails. If the first clone partially succeeded (e.g. the server returned HTTP 502 during checkout), the cache directory is left non-empty, and the retry fails with "destination path ... already exists and is not an empty directory". Remove the directory before retrying so the fallback can proceed. --- lib/rbs/collection/sources/git.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/rbs/collection/sources/git.rb b/lib/rbs/collection/sources/git.rb index e4277dea3d..8fcc92b8dc 100644 --- a/lib/rbs/collection/sources/git.rb +++ b/lib/rbs/collection/sources/git.rb @@ -140,6 +140,12 @@ def to_lockfile # git v2.27.0 or greater git 'clone', '--filter=blob:none', remote, git_dir.to_s, chdir: nil rescue CommandError + # The failed `--filter=blob:none` clone may leave behind a + # partial repository (e.g. when the server returned an error + # mid-clone), which would cause the fallback `git clone` to + # fail with "destination path ... already exists and is not + # an empty directory". Clean it up before retrying. + FileUtils.rm_rf(git_dir) git 'clone', remote, git_dir.to_s, chdir: nil end end