Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/cob: Add `delete` subcommand
✗ 0/1 checks passed 2color wants to merge 1 commit into master · opened 1 month ago

Wire up Store::remove to the rad cob CLI, matching the pattern used by rad issue delete and rad patch delete. Supports Issue, Patch, and external COB types. Identity deletion is rejected with an error.

This is soft delete: it removes the git reference that points to the COB, then re-signs the refs. The underlying git objects remain in the object store as unreachable objects that could get GCed.

Some checks failed — 0 passed, 1 failed View logs ↗
2 files changed +44 -0 e7467fb1 2099263d
modified crates/radicle-cli/src/commands/cob.rs
@@ -162,6 +162,35 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                return Err(e);
            }
        }
+
        Delete {
+
            repo,
+
            type_name,
+
            object,
+
        } => {
+
            let signer = &profile.signer()?;
+
            let repo = storage.repository_mut(repo)?;
+
            let oid = object.resolve::<radicle::git::Oid>(&repo.backend)?.into();
+

+
            match type_name {
+
                Patch => {
+
                    let store: Store<cob::patch::Patch, _> = Store::open(&repo)?;
+
                    store.remove(&oid, signer)?;
+
                }
+
                Issue => {
+
                    let store: Store<cob::issue::Issue, _> = Store::open(&repo)?;
+
                    store.remove(&oid, signer)?;
+
                }
+
                Identity => anyhow::bail!(
+
                    "Deletion of collaborative objects of type {} is not supported.",
+
                    &type_name
+
                ),
+
                Other(type_name) => {
+
                    let store: Store<cob::external::External, _> =
+
                        Store::open_for(&type_name, &repo)?;
+
                    store.remove(&oid, signer)?;
+
                }
+
            }
+
        }
        Update(args::Update {
            repo,
            type_name,
modified crates/radicle-cli/src/commands/cob/args.rs
@@ -88,6 +88,21 @@ pub(super) enum Command {

    /// Add actions to a COB
    Update(#[clap(flatten)] Update),
+

+
    /// Delete a COB
+
    Delete {
+
        /// Repository ID of the repository to operate on
+
        #[arg(long, short, value_name = "RID")]
+
        repo: RepoId,
+

+
        /// Typename of the object to delete
+
        #[arg(long = "type", short, value_name = "TYPENAME")]
+
        type_name: FilteredTypeName,
+

+
        /// Object ID of the object to delete
+
        #[arg(long, short, value_name = "OID")]
+
        object: Rev,
+
    },
}

#[derive(Parser, Debug)]