From 11e8b89b207ec5f6ba51c66e1c369c71ecd731f3 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Sat, 6 Sep 2025 11:25:14 +0300 Subject: [PATCH] radicle/src/git: additionally specify pruneTags for remote Ensure that, when adding a remote, `pruneTags` is set to `false` so that tags are not pruned when fetching from a remote's namespace. --- crates/radicle/src/git.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/radicle/src/git.rs b/crates/radicle/src/git.rs index 3e038516..89465cf9 100644 --- a/crates/radicle/src/git.rs +++ b/crates/radicle/src/git.rs @@ -597,7 +597,16 @@ pub fn configure_repository(repo: &git2::Repository) -> Result<(), git2::Error> /// fetch = +refs/heads/*:refs/remotes//* /// fetch = +refs/tags/*:refs/remotes//tags/* /// tagOpt = --no-tags +/// pruneTags = false /// ``` +/// +/// Because of the `+refs/tags/*:…` refspec, set: +/// 1. `pruneTags = false` to ensure that `git` does not delete tags because +/// the remote does not have them. Tags for a Radicle repository are +/// synthesised by canonical refs and thus, the `rad` remote will handle +/// fetching them. +/// 2. `tagOpt = --no-tags` to ensure that tags are not fetched and stored +/// under `refs/tags`, again, because these are fetched by the `rad` remote. pub fn configure_remote<'r>( repo: &'r git2::Repository, name: &str, @@ -613,11 +622,9 @@ pub fn configure_remote<'r>( let tags = format!("+refs/tags/*:refs/remotes/{name}/tags/*"); repo.remote_add_fetch(name, &tags)?; - // Because of the above, if we don't set `--no-tags` then the tags will be - // fetched into `refs/tags` as well. We don't want to do this *unless* it's - // the `rad` remote, which will have the canonical tags if name != (*rad::REMOTE_NAME).as_str() { let mut config = repo.config()?; + config.set_bool(&format!("remote.{name}.pruneTags"), false)?; config.set_str(&format!("remote.{name}.tagOpt"), "--no-tags")?; }