Skip to content

Commit 92fe9eb

Browse files
authored
Merge pull request #2978 from zonuexe/fix/collection-partial-clone-cleanup
Clean up partial clone before falling back to full clone
2 parents 81a3502 + 096e3c7 commit 92fe9eb

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)