mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
Add the remaining `Patch` actions to the CLI interface. These include: - React to a revision - Edit a comment - React to a comment - Redact a comment The `react` subcommand is added in a straight-forward manner. The comment commands are slightly less straight-forward. In order to keep to one layer of subcommands, these variants are done through the `rad patch comment` subcommand. They are accessed via options: `--edit`, `--react`, and `--redact`, respectively. Each of these options takes the `CommentId` for which the action is affecting. The `message`, `react` (introduced for `rad patch react`), and `undo` variables repurposed for this subset of actions.
36 lines
978 B
Rust
36 lines
978 B
Rust
use anyhow::anyhow;
|
|
|
|
use radicle::cob;
|
|
use radicle::cob::{patch, Reaction};
|
|
use radicle::patch::cache::Patches as _;
|
|
use radicle::patch::ByRevision;
|
|
use radicle::storage::git::Repository;
|
|
use radicle::Profile;
|
|
|
|
use crate::git;
|
|
use crate::terminal as term;
|
|
|
|
pub fn run(
|
|
revision_id: &git::Rev,
|
|
reaction: Reaction,
|
|
active: bool,
|
|
repo: &Repository,
|
|
profile: &Profile,
|
|
) -> anyhow::Result<()> {
|
|
let signer = term::signer(profile)?;
|
|
let mut patches = profile.patches_mut(repo)?;
|
|
let revision_id = revision_id.resolve::<cob::EntryId>(&repo.backend)?;
|
|
let ByRevision {
|
|
id: patch_id,
|
|
patch,
|
|
revision_id,
|
|
..
|
|
} = patches
|
|
.find_by_revision(&patch::RevisionId::from(revision_id))?
|
|
.ok_or_else(|| anyhow!("Patch revision `{revision_id}` not found"))?;
|
|
let mut patch = patch::PatchMut::new(patch_id, patch, &mut patches);
|
|
patch.react(revision_id, reaction, None, active, &signer)?;
|
|
|
|
Ok(())
|
|
}
|