Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle/src/git: additionally specify pruneTags for remote
✓ CI success Fintan Halpenny committed 8 months ago
commit 7ed294c98b0a58760a303c5570098eaf3bd79c0f
parent f00d1d67432882bef11fc940601f071efe55c88d
2 passed (2 total) View logs
1 file changed +15 -4
modified crates/radicle/src/git.rs
@@ -597,7 +597,20 @@ pub fn configure_repository(repo: &git2::Repository) -> Result<(), git2::Error>
///   fetch = +refs/heads/*:refs/remotes/<name>/*
///   fetch = +refs/tags/*:refs/remotes/<name>/tags/*
///   tagOpt = --no-tags
-
/// ```
+
///   pruneTags = false
+
///     ```
+
///
+
/// Because of the `refs/tags/*` refspec, we have to set two options:
+
///   * `pruneTags = false`, and
+
///   * `tagOpt = --no-tags`
+
///
+
/// The `pruneTags` is to ensure that `git` does not delete tags because the
+
/// remote has them. Tags for a Radicle repository are synthesised by canonical
+
/// refs and thus, the `rad` remote will handle fetching them.
+
///
+
/// The `tagOpt` is to ensure that we do not fetch the tags from the remote and
+
/// put them under `refs/tags`, again, because these are fetched by the `rad`
+
/// remote.
pub fn configure_remote<'r>(
    repo: &'r git2::Repository,
    name: &str,
@@ -613,12 +626,10 @@ 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_str(&format!("remote.{name}.tagOpt"), "--no-tags")?;
+
        config.set_bool(&format!("remote.{name}.pruneTags"), false)?;
    }

    if push != fetch {