Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Allow edit revision embeds
Sebastian Martinez committed 2 years ago
commit ee3dcfacf0a5bcde385afa81f4dd1c086183535f
parent 5331cf3bcf2dd75f33d75173116137c3091aaf05
3 files changed +27 -5
modified 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::<Vec<_>>();

    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(())
    })?;
modified 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<Embed> = 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,
modified radicle/src/cob/patch.rs
@@ -442,6 +442,12 @@ impl Patch {
        r.description()
    }

+
    /// Patch embeds.
+
    pub fn embeds(&self) -> &Vec<Embed<Uri>> {
+
        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<Embed<Uri>> {
+
        &self.description.last().embeds
+
    }
+

    /// Author of the revision.
    pub fn author(&self) -> &Author {
        &self.author