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 <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2024-03-01 10:51:13 +00:00 committed by cloudhead
parent 3a2e06e498
commit 96c65eb2b3
No known key found for this signature in database
2 changed files with 15 additions and 0 deletions

View File

@ -435,6 +435,16 @@ pub fn show(
for line in timeline::timeline(profile, patch) { for line in timeline::timeline(profile, patch) {
widget.push(line); 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(); widget.print();
Ok(()) Ok(())

View File

@ -1420,6 +1420,11 @@ impl Revision {
&self.discussion &self.discussion
} }
/// Iterate over all top-level replies.
pub fn replies(&self) -> impl Iterator<Item = (&CommentId, &thread::Comment<CodeLocation>)> {
self.discussion.comments()
}
/// Reviews of this revision's changes (one per actor). /// Reviews of this revision's changes (one per actor).
pub fn reviews(&self) -> impl DoubleEndedIterator<Item = (&PublicKey, &Review)> { pub fn reviews(&self) -> impl DoubleEndedIterator<Item = (&PublicKey, &Review)> {
self.reviews self.reviews