mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
cli: add un/resolve for patch review comments
Patch review comments can be resolved and unresolved as part of the Patch COB API. This functionality was missing from the `rad patch command`. Add a subcommand `rad patch resolve` which can resolve a review comment, and unresolve given the `--undo` flag. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
use anyhow::anyhow;
|
||||
use radicle::cob::thread::CommentId;
|
||||
use radicle::patch::{self, PatchId};
|
||||
use radicle::patch::{cache::Patches as _, ReviewId};
|
||||
use radicle::storage::git::Repository;
|
||||
use radicle::Profile;
|
||||
|
||||
use crate::terminal as term;
|
||||
|
||||
pub fn resolve(
|
||||
patch_id: PatchId,
|
||||
review: ReviewId,
|
||||
comment: CommentId,
|
||||
repo: &Repository,
|
||||
profile: &Profile,
|
||||
) -> anyhow::Result<()> {
|
||||
let signer = term::signer(profile)?;
|
||||
let mut patches = profile.patches_mut(repo)?;
|
||||
let patch = patches
|
||||
.get(&patch_id)?
|
||||
.ok_or_else(|| anyhow!("Patch `{patch_id}` not found"))?;
|
||||
let mut patch = patch::PatchMut::new(patch_id, patch, &mut patches);
|
||||
patch.resolve_review_comment(review, comment, &signer)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn unresolve(
|
||||
patch_id: PatchId,
|
||||
review: ReviewId,
|
||||
comment: CommentId,
|
||||
repo: &Repository,
|
||||
profile: &Profile,
|
||||
) -> anyhow::Result<()> {
|
||||
let signer = term::signer(profile)?;
|
||||
let mut patches = profile.patches_mut(repo)?;
|
||||
let patch = patches
|
||||
.get(&patch_id)?
|
||||
.ok_or_else(|| anyhow!("Patch `{patch_id}` not found"))?;
|
||||
let mut patch = patch::PatchMut::new(patch_id, patch, &mut patches);
|
||||
patch.unresolve_review_comment(review, comment, &signer)?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user