From 96c65eb2b39d8adcb80ecc9a0cd3241fca394221 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 1 Mar 2024 10:51:13 +0000 Subject: [PATCH] cli: add replies to patch show output If any replies to patches were made, it was not possible to see them in the output of `rad patch show`. Add the replies to show output, but only if the `--verbose` flag is set. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/src/terminal/patch.rs | 10 ++++++++++ radicle/src/cob/patch.rs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/radicle-cli/src/terminal/patch.rs b/radicle-cli/src/terminal/patch.rs index 2ee4f1a5..e84cea99 100644 --- a/radicle-cli/src/terminal/patch.rs +++ b/radicle-cli/src/terminal/patch.rs @@ -435,6 +435,16 @@ pub fn show( for line in timeline::timeline(profile, patch) { widget.push(line); } + + if verbose { + for (id, comment) in revision.replies() { + let hstack = term::comment::header(id, comment, profile); + + widget = widget.divider(); + widget.push(hstack); + widget.push(term::textarea(comment.body()).wrap(60)); + } + } widget.print(); Ok(()) diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index c33d9122..3cf6b1a0 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -1420,6 +1420,11 @@ impl Revision { &self.discussion } + /// Iterate over all top-level replies. + pub fn replies(&self) -> impl Iterator)> { + self.discussion.comments() + } + /// Reviews of this revision's changes (one per actor). pub fn reviews(&self) -> impl DoubleEndedIterator { self.reviews