diff --git a/radicle-cli/src/commands/patch/edit.rs b/radicle-cli/src/commands/patch/edit.rs index b7497555..3526ff69 100644 --- a/radicle-cli/src/commands/patch/edit.rs +++ b/radicle-cli/src/commands/patch/edit.rs @@ -1,6 +1,6 @@ use super::*; -use radicle::cob::patch; +use radicle::cob::{patch, resolve_embed}; use radicle::prelude::*; use radicle::storage::git::Repository; @@ -38,13 +38,18 @@ pub fn run( let (root, _) = patch.root(); let target = patch.target(); + let embeds = patch + .embeds() + .into_iter() + .filter_map(|embed| resolve_embed(repository, embed.clone())) + .collect::>(); patch.transaction("Edit", &signer, |tx| { if let Some(t) = title { tx.edit(t, target)?; } if let Some(d) = description { - tx.edit_revision(root, d, Vec::default())?; + tx.edit_revision(root, d, embeds)?; } Ok(()) })?; diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index d959a23b..c4665683 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize}; use serde_json::json; use tower_http::set_header::SetResponseHeaderLayer; -use radicle::cob::{issue, patch, Embed, Label, Uri}; +use radicle::cob::{issue, patch, resolve_embed, Embed, Label, Uri}; use radicle::identity::{Did, Id, Visibility}; use radicle::node::routing::Store; use radicle::node::{AliasStore, Node, NodeId}; @@ -24,7 +24,7 @@ use radicle_surf::{diff, Glob, Oid, Repository}; use crate::api::error::Error; use crate::api::project::Info; -use crate::api::{self, announce_refs, resolve_embed, CobsQuery, Context, PaginationQuery}; +use crate::api::{self, announce_refs, CobsQuery, Context, PaginationQuery}; use crate::axum_extra::{Path, Query}; const CACHE_1_HOUR: &str = "public, max-age=3600, must-revalidate"; @@ -844,7 +844,14 @@ async fn patch_update_handler( patch::Action::RevisionEdit { revision, description, - } => patch.edit_revision(revision, description, &signer)?, + embeds, + } => { + let embeds: Vec = embeds + .into_iter() + .filter_map(|embed| resolve_embed(&repo, embed)) + .collect(); + patch.edit_revision(revision, description, embeds, &signer)? + } patch::Action::RevisionRedact { revision } => patch.redact(revision, &signer)?, patch::Action::RevisionComment { revision, diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 715756bb..1eb7ef4a 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -442,6 +442,12 @@ impl Patch { r.description() } + /// Patch embeds. + pub fn embeds(&self) -> &Vec> { + let (_, r) = self.root(); + r.embeds() + } + /// Author of the first revision of the patch. pub fn author(&self) -> &Author { &self.author @@ -1302,6 +1308,10 @@ impl Revision { self.description.last().body.as_str() } + pub fn embeds(&self) -> &Vec> { + &self.description.last().embeds + } + /// Author of the revision. pub fn author(&self) -> &Author { &self.author