Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Update heartwood crates to commit `2d13591`
Open did:key:z6MkkfM3...sVz5 opened 1 year ago
  • Add migrate::ignore callback to cob::cache calls
  • Remove the Verified trait from the Doc struct
  • Update Doc fields with read-only methods

Also changes the Author::new method to take a reference to identity::Did

checkcheck-e2e

👉 Workflow runs 👉 Branch on GitHub

10 files changed +75 -62 06437656 46703705
modified Cargo.lock
@@ -3748,7 +3748,7 @@ dependencies = [
[[package]]
name = "radicle"
version = "0.13.0"
-
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#855327d303566aac1d3e065d4ba7e16d9ccd18e6"
+
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#2d13591ec21e6ce04678e2965f08d145cf2d76ae"
dependencies = [
 "amplify",
 "base64 0.21.7",
@@ -3778,7 +3778,7 @@ dependencies = [
[[package]]
name = "radicle-cob"
version = "0.12.0"
-
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#855327d303566aac1d3e065d4ba7e16d9ccd18e6"
+
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#2d13591ec21e6ce04678e2965f08d145cf2d76ae"
dependencies = [
 "fastrand",
 "git2",
@@ -3796,7 +3796,7 @@ dependencies = [
[[package]]
name = "radicle-crypto"
version = "0.11.0"
-
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#855327d303566aac1d3e065d4ba7e16d9ccd18e6"
+
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#2d13591ec21e6ce04678e2965f08d145cf2d76ae"
dependencies = [
 "amplify",
 "cyphernet",
@@ -3814,7 +3814,7 @@ dependencies = [
[[package]]
name = "radicle-dag"
version = "0.9.0"
-
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#855327d303566aac1d3e065d4ba7e16d9ccd18e6"
+
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#2d13591ec21e6ce04678e2965f08d145cf2d76ae"
dependencies = [
 "fastrand",
]
@@ -3836,7 +3836,7 @@ dependencies = [
[[package]]
name = "radicle-ssh"
version = "0.9.0"
-
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#855327d303566aac1d3e065d4ba7e16d9ccd18e6"
+
source = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git#2d13591ec21e6ce04678e2965f08d145cf2d76ae"
dependencies = [
 "byteorder",
 "log",
@@ -6063,7 +6063,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
-
 "windows-sys 0.59.0",
+
 "windows-sys 0.48.0",
]

[[package]]
modified crates/radicle-types/src/cobs.rs
@@ -22,10 +22,10 @@ pub struct Author {
}

impl Author {
-
    pub fn new(did: identity::Did, aliases: &impl AliasStore) -> Self {
+
    pub fn new(did: &identity::Did, aliases: &impl AliasStore) -> Self {
        Self {
-
            did,
-
            alias: aliases.alias(&did),
+
            did: *did,
+
            alias: aliases.alias(did),
        }
    }
}
modified crates/radicle-types/src/cobs/issue.rs
@@ -36,12 +36,12 @@ impl Issue {

        Self {
            id: id.to_string(),
-
            author: cobs::Author::new(*issue.author().id(), aliases),
+
            author: cobs::Author::new(issue.author().id(), aliases),
            title: issue.title().to_string(),
            state: (*issue.state()).into(),
            assignees: issue
                .assignees()
-
                .map(|did| cobs::Author::new(*did, aliases))
+
                .map(|did| cobs::Author::new(did, aliases))
                .collect::<Vec<_>>(),
            body: cobs::thread::Comment::<cobs::Never>::new(
                *root_oid,
modified crates/radicle-types/src/cobs/patch.rs
@@ -37,14 +37,14 @@ impl Patch {
    pub fn new(id: patch::PatchId, patch: &patch::Patch, aliases: &impl AliasStore) -> Self {
        Self {
            id: id.to_string(),
-
            author: cobs::Author::new(*patch.author().id(), aliases),
+
            author: cobs::Author::new(patch.author().id(), aliases),
            title: patch.title().to_string(),
            state: patch.state().clone().into(),
            base: *patch.base(),
            head: *patch.head(),
            assignees: patch
                .assignees()
-
                .map(|did| cobs::Author::new(did, aliases))
+
                .map(|did| cobs::Author::new(&did, aliases))
                .collect::<Vec<_>>(),
            labels: patch.labels().cloned().collect::<Vec<_>>(),
            timestamp: patch.timestamp(),
@@ -142,7 +142,7 @@ impl Revision {
    pub fn new(value: cob::patch::Revision, aliases: &impl AliasStore) -> Self {
        Self {
            id: value.id(),
-
            author: cobs::Author::new(*value.author().id(), aliases),
+
            author: cobs::Author::new(value.author().id(), aliases),
            description: value
                .edits()
                .map(|e| Edit::new(e, aliases))
@@ -181,7 +181,7 @@ impl Revision {
                        .map(|(emoji, authors)| {
                            cobs::thread::Reaction::new(
                                *emoji,
-
                                authors,
+
                                authors.into_iter().map(Into::into).collect::<Vec<_>>(),
                                location
                                    .as_ref()
                                    .map(|l| cobs::thread::CodeLocation::new(l.clone())),
@@ -211,7 +211,7 @@ pub struct Edit {
impl Edit {
    pub fn new(edit: &cob::thread::Edit, aliases: &impl AliasStore) -> Self {
        Self {
-
            author: cobs::Author::new(edit.author.into(), aliases),
+
            author: cobs::Author::new(&edit.author.into(), aliases),
            timestamp: edit.timestamp,
            body: edit.body.clone(),
            embeds: edit
@@ -251,7 +251,7 @@ impl Review {
    ) -> Self {
        Self {
            id,
-
            author: cobs::Author::new(review.author().id, aliases),
+
            author: cobs::Author::new(&review.author().id, aliases),
            verdict: review.verdict(),
            summary: review.summary().map(|s| s.to_string()),
            comments: review
modified crates/radicle-types/src/cobs/thread.rs
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use ts_rs::TS;

use radicle::node::AliasStore;
-
use radicle::{cob, crypto, git};
+
use radicle::{cob, git, identity};

use crate::cobs;

@@ -59,7 +59,7 @@ impl Comment<CodeLocation> {
    ) -> Self {
        Self {
            id,
-
            author: cobs::Author::new(comment.author().into(), aliases),
+
            author: cobs::Author::new(&comment.author().into(), aliases),
            edits: comment
                .edits()
                .map(|e| cobs::patch::Edit::new(e, aliases))
@@ -68,7 +68,12 @@ impl Comment<CodeLocation> {
                .reactions()
                .into_iter()
                .map(|(reaction, authors)| {
-
                    cobs::thread::Reaction::new(*reaction, authors, None, aliases)
+
                    cobs::thread::Reaction::new(
+
                        *reaction,
+
                        authors.into_iter().map(Into::into).collect(),
+
                        None,
+
                        aliases,
+
                    )
                })
                .collect::<Vec<_>>(),
            reply_to: comment.reply_to(),
@@ -92,7 +97,7 @@ impl Comment<cobs::Never> {
    ) -> Self {
        Self {
            id,
-
            author: cobs::Author::new(comment.author().into(), aliases),
+
            author: cobs::Author::new(&comment.author().into(), aliases),
            edits: comment
                .edits()
                .map(|e| cobs::patch::Edit::new(e, aliases))
@@ -101,7 +106,12 @@ impl Comment<cobs::Never> {
                .reactions()
                .into_iter()
                .map(|(reaction, authors)| {
-
                    cobs::thread::Reaction::new(*reaction, authors, None, aliases)
+
                    cobs::thread::Reaction::new(
+
                        *reaction,
+
                        authors.into_iter().map(Into::into).collect::<Vec<_>>(),
+
                        None,
+
                        aliases,
+
                    )
                })
                .collect::<Vec<_>>(),
            reply_to: comment.reply_to(),
@@ -132,7 +142,7 @@ pub struct Reaction {
impl Reaction {
    pub fn new(
        emoji: cob::Reaction,
-
        authors: Vec<&crypto::PublicKey>,
+
        authors: Vec<identity::Did>,
        location: Option<CodeLocation>,
        aliases: &impl AliasStore,
    ) -> Self {
@@ -140,7 +150,7 @@ impl Reaction {
            emoji,
            authors: authors
                .into_iter()
-
                .map(|a| cobs::Author::new(a.into(), aliases))
+
                .map(|did| cobs::Author::new(&did, aliases))
                .collect::<Vec<_>>(),
            location,
        }
modified crates/radicle-types/src/traits/cobs.rs
@@ -1,3 +1,4 @@
+
use radicle::cob::migrate;
use radicle::cob::object::Storage;
use radicle::storage::refs::draft;
use radicle::storage::{self, ReadStorage};
@@ -27,7 +28,7 @@ pub trait Cobs: Profile {
                    Some(crate::cobs::issue::Operation {
                        entry_id: op.id,
                        action,
-
                        author: crate::cobs::Author::new(op.author.into(), &aliases),
+
                        author: crate::cobs::Author::new(&op.author.into(), &aliases),
                        timestamp: op.timestamp,
                    })
                },
@@ -58,7 +59,7 @@ pub trait Cobs: Profile {
            &draft_oid.into(),
        )?;

-
        let mut patches = profile.patches_mut(&repo)?;
+
        let mut patches = profile.patches_mut(&repo, migrate::ignore)?;
        patches.write(&cob_id.into())?;

        storage::git::cob::DraftStore::new(&repo, *signer.public_key()).remove(
modified crates/radicle-types/src/traits/issue.rs
@@ -1,3 +1,4 @@
+
use radicle::cob::migrate;
use radicle::issue::cache::Issues as _;
use radicle::node::Handle;
use radicle::storage::ReadStorage;
@@ -16,7 +17,7 @@ pub trait Issues: Profile {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
        let status = status.unwrap_or_default();
-
        let issues = profile.issues(&repo)?;
+
        let issues = profile.issues(&repo, migrate::ignore)?;
        let mut issues: Vec<_> = issues
            .list()?
            .filter_map(|r| {
@@ -42,7 +43,7 @@ pub trait Issues: Profile {
    ) -> Result<Option<cobs::issue::Issue>, Error> {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
-
        let issues = profile.issues(&repo)?;
+
        let issues = profile.issues(&repo, migrate::ignore)?;
        let issue = issues.get(&id.into())?;

        let aliases = &profile.aliases();
@@ -58,7 +59,7 @@ pub trait Issues: Profile {
    ) -> Result<Option<Vec<cobs::thread::Thread>>, Error> {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
-
        let issues = profile.issues(&repo)?;
+
        let issues = profile.issues(&repo, migrate::ignore)?;
        let issue = issues.get(&id.into())?;

        let aliases = &profile.aliases();
@@ -103,13 +104,13 @@ pub trait IssuesMut: Profile {
        let repo = profile.storage.repository(rid)?;
        let signer = profile.signer()?;
        let aliases = profile.aliases();
-
        let mut issues = profile.issues_mut(&repo)?;
+
        let mut issues = profile.issues_mut(&repo, migrate::ignore)?;
        let issue = issues.create(
            new.title,
            new.description,
            &new.labels,
            &new.assignees,
-
            new.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
            new.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
            &signer,
        )?;

@@ -132,7 +133,7 @@ pub trait IssuesMut: Profile {
        let repo = profile.storage.repository(rid)?;
        let signer = profile.signer()?;
        let aliases = profile.aliases();
-
        let mut issues = profile.issues_mut(&repo)?;
+
        let mut issues = profile.issues_mut(&repo, migrate::ignore)?;
        let mut issue = issues.get_mut(&cob_id.into())?;

        match action {
@@ -163,7 +164,7 @@ pub trait IssuesMut: Profile {
                issue.comment(
                    body,
                    reply_to.unwrap_or(cob_id),
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -171,7 +172,7 @@ pub trait IssuesMut: Profile {
                issue.edit_comment(
                    id,
                    body,
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
modified crates/radicle-types/src/traits/patch.rs
@@ -1,3 +1,4 @@
+
use radicle::cob::migrate;
use radicle::node::Handle;
use radicle::patch::cache::Patches as _;
use radicle::storage;
@@ -21,7 +22,7 @@ pub trait Patches: Profile {
        let take = take.unwrap_or(20);
        let repo = profile.storage.repository(rid)?;
        let aliases = &profile.aliases();
-
        let cache = profile.patches(&repo)?;
+
        let cache = profile.patches(&repo, migrate::ignore)?;
        let patches = match status {
            None => cache.list()?.collect::<Vec<_>>(),
            Some(s) => cache.list_by_status(&s.into())?.collect::<Vec<_>>(),
@@ -54,7 +55,7 @@ pub trait Patches: Profile {
    ) -> Result<Option<cobs::patch::Patch>, Error> {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
-
        let patches = profile.patches(&repo)?;
+
        let patches = profile.patches(&repo, migrate::ignore)?;
        let patch = patches.get(&id.into())?;
        let aliases = &profile.aliases();
        let patches = patch.map(|patch| cobs::patch::Patch::new(id.into(), &patch, aliases));
@@ -69,7 +70,7 @@ pub trait Patches: Profile {
    ) -> Result<Option<Vec<cobs::patch::Revision>>, Error> {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
-
        let patches = profile.patches(&repo)?;
+
        let patches = profile.patches(&repo, migrate::ignore)?;
        let revisions = patches.get(&id.into())?.map(|patch| {
            let aliases = &profile.aliases();

@@ -90,7 +91,7 @@ pub trait Patches: Profile {
    ) -> Result<Option<cobs::patch::Revision>, Error> {
        let profile = self.profile();
        let repo = profile.storage.repository(rid)?;
-
        let patches = profile.patches(&repo)?;
+
        let patches = profile.patches(&repo, migrate::ignore)?;
        let revision = patches.get(&id.into())?.and_then(|patch| {
            let aliases = &profile.aliases();

@@ -116,7 +117,7 @@ pub trait PatchesMut: Profile {
        let repo = profile.storage.repository(rid)?;
        let signer = profile.signer()?;
        let aliases = profile.aliases();
-
        let mut patches = profile.patches_mut(&repo)?;
+
        let mut patches = profile.patches_mut(&repo, migrate::ignore)?;
        let mut patch = patches.get_mut(&cob_id.into())?;

        match action {
@@ -128,7 +129,7 @@ pub trait PatchesMut: Profile {
                patch.edit_revision(
                    revision,
                    description,
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -186,7 +187,7 @@ pub trait PatchesMut: Profile {
                    body,
                    location.map(|l| l.into()),
                    reply_to,
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -200,7 +201,7 @@ pub trait PatchesMut: Profile {
                    review,
                    comment,
                    body,
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -239,7 +240,7 @@ pub trait PatchesMut: Profile {
                    body,
                    reply_to,
                    location.map(|l| l.into()),
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -253,7 +254,7 @@ pub trait PatchesMut: Profile {
                    revision,
                    comment,
                    body,
-
                    embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                    embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                    &signer,
                )?;
            }
@@ -408,7 +409,7 @@ pub trait PatchesMut: Profile {
                new.body,
                new.location.map(|l| l.into()),
                new.reply_to,
-
                new.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                new.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
            )?;

            Ok(())
modified crates/radicle-types/src/traits/repo.rs
@@ -1,7 +1,7 @@
+
use radicle::cob::migrate;
use radicle_surf as surf;
use serde::{Deserialize, Serialize};

-
use radicle::crypto::Verified;
use radicle::identity::{doc, Doc, DocAt};
use radicle::issue::cache::Issues as _;
use radicle::node::routing::Store;
@@ -40,7 +40,7 @@ pub trait Repo: Profile {
                continue;
            }

-
            if !doc.delegates.contains(&profile.public_key.into()) && show == Show::Delegate {
+
            if !doc.delegates().contains(&profile.public_key.into()) && show == Show::Delegate {
                continue;
            }

@@ -87,27 +87,26 @@ pub trait Repo: Profile {
    fn repo_info(
        &self,
        repo: &storage::git::Repository,
-
        doc: &Doc<Verified>,
+
        doc: &Doc,
    ) -> Result<repo::RepoInfo, Error> {
        let profile = self.profile();
        let aliases = profile.aliases();
        let delegates = doc
-
            .delegates
-
            .clone()
-
            .into_iter()
+
            .delegates()
+
            .iter()
            .map(|did| cobs::Author::new(did, &aliases))
            .collect::<Vec<_>>();
        let db = profile.database()?;
        let seeding = db.count(&repo.id).unwrap_or_default();
        let project = doc
-
            .payload
+
            .payload()
            .get(&doc::PayloadId::project())
            .and_then(|payload| {
                let (_, head) = repo.head().ok()?;
                let commit = repo.commit(head).ok()?;
-
                let patches = profile.patches(repo).ok()?;
+
                let patches = profile.patches(repo, migrate::ignore).ok()?;
                let patches = patches.counts().ok()?;
-
                let issues = profile.issues(repo).ok()?;
+
                let issues = profile.issues(repo, migrate::ignore).ok()?;
                let issues = issues.counts().ok()?;

                let data: repo::ProjectPayloadData = (*payload).clone().try_into().ok()?;
@@ -124,8 +123,8 @@ pub trait Repo: Profile {
        Ok::<_, Error>(repo::RepoInfo {
            payloads: repo::SupportedPayloads { project },
            delegates,
-
            threshold: doc.threshold,
-
            visibility: doc.visibility.clone().into(),
+
            threshold: doc.threshold(),
+
            visibility: doc.visibility().clone().into(),
            rid: repo.id,
            seeding,
        })
modified crates/radicle-types/src/traits/thread.rs
@@ -2,6 +2,7 @@ use base64::{engine::general_purpose::STANDARD, Engine as _};
use localtime::LocalTime;

use radicle::cob;
+
use radicle::cob::cache::migrate;
use radicle::git;
use radicle::identity;
use radicle::node::Handle;
@@ -46,7 +47,7 @@ pub trait Thread: Profile {
        let mut node = Node::new(profile.socket());
        let signer = profile.signer()?;
        let repo = profile.storage.repository(rid)?;
-
        let mut issues = profile.issues_mut(&repo)?;
+
        let mut issues = profile.issues_mut(&repo, migrate::ignore)?;
        let mut issue = issues.get_mut(&new.id.into())?;
        let id = new.reply_to.unwrap_or_else(|| {
            let (root_id, _) = issue.root();
@@ -56,7 +57,7 @@ pub trait Thread: Profile {
        let oid = issue.comment(
            n.body,
            id,
-
            n.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
            n.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
            &signer,
        )?;

@@ -71,7 +72,7 @@ pub trait Thread: Profile {
                new.body,
                id.into(),
                None,
-
                new.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                new.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                LocalTime::now().into(),
            ),
            aliases,
@@ -89,7 +90,7 @@ pub trait Thread: Profile {
        let mut node = Node::new(profile.socket());
        let signer = profile.signer()?;
        let repo = profile.storage.repository(rid)?;
-
        let mut patches = profile.patches_mut(&repo)?;
+
        let mut patches = profile.patches_mut(&repo, migrate::ignore)?;
        let mut patch = patches.get_mut(&new.id.into())?;
        let n = new.clone();
        let oid = patch.comment(
@@ -97,7 +98,7 @@ pub trait Thread: Profile {
            n.body,
            n.reply_to,
            n.location.map(|l| l.into()),
-
            n.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
            n.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
            &signer,
        )?;

@@ -112,7 +113,7 @@ pub trait Thread: Profile {
                new.body,
                new.reply_to,
                new.location.map(|l| l.into()),
-
                new.embeds.into_iter().map(|e| e.into()).collect::<Vec<_>>(),
+
                new.embeds.into_iter().map(Into::into).collect::<Vec<_>>(),
                LocalTime::now().into(),
            ),
            aliases,