Skip to content

Commit 096e3c7

Browse files
committed
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.
1 parent fcc1685 commit 096e3c7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • lib/rbs/collection/sources

lib/rbs/collection/sources/git.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ def to_lockfile
140140
# git v2.27.0 or greater
141141
git 'clone', '--filter=blob:none', remote, git_dir.to_s, chdir: nil
142142
rescue CommandError
143+
# The failed `--filter=blob:none` clone may leave behind a
144+
# partial repository (e.g. when the server returned an error
145+
# mid-clone), which would cause the fallback `git clone` to
146+
# fail with "destination path ... already exists and is not
147+
# an empty directory". Clean it up before retrying.
148+
FileUtils.rm_rf(git_dir)
143149
git 'clone', remote, git_dir.to_s, chdir: nil
144150
end
145151
end

0 commit comments

Comments
 (0)