Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/cob: Add `delete` subcommand
✗ CI failure Daniel Norman committed 1 month ago
commit 2099263dfb8eee45083bc2975507cf9dc052af32
parent e7467fb15ff6d679d710c0ee9b6f6d2b94d4c69d
1 failed (1 total) View logs
2 files changed +44 -0
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)]