node: Make sure not to prune on initial fetch

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-09-14 18:27:02 +02:00
parent 59ccfdda77
commit d7a2520ad3
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -380,6 +380,7 @@ impl<'r> WriteRepository<'r> for Repository {
let staging_repo = builder let staging_repo = builder
.bare(true) .bare(true)
// TODO: Comment // TODO: Comment
// TODO: Due to this, I think we'll have to run GC when there is a failure.
.clone_local(git2::build::CloneLocal::Local) .clone_local(git2::build::CloneLocal::Local)
.clone( .clone(
&git::Url { &git::Url {
@ -391,9 +392,13 @@ impl<'r> WriteRepository<'r> for Repository {
&path, &path,
)?; )?;
// In case we fetch an invalid update, we want to make sure nothing is deleted.
let mut opts = git2::FetchOptions::default();
opts.prune(git2::FetchPrune::Off);
staging_repo staging_repo
.remote_anonymous(&url)? .remote_anonymous(&url)?
.fetch(refs, None, None)?; .fetch(refs, Some(&mut opts), None)?;
// TODO: Comment // TODO: Comment
Repository::from(staging_repo).verify()?; Repository::from(staging_repo).verify()?;