Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add flag to "rad patch list" to list only patches commented by someone
✗ CI failure Matthias Beyer committed 7 months ago
commit 906a7b975e5cc0f773e070f58bbd060375532dd3
parent a62c82baacee683da3159c123ed0cd5bf0c0c7d7
2 passed 1 failed (3 total) View logs
2 files changed +42 -2
modified crates/radicle-cli/src/commands/patch.rs
@@ -43,7 +43,7 @@ pub const HELP: Help = Help {
Usage

    rad patch [<option>...]
-
    rad patch list [--all|--merged|--open|--archived|--draft|--authored] [--author <did>]... [<option>...]
+
    rad patch list [--all|--merged|--open|--archived|--draft|--authored] [--author <did>]... [--commented <did>] [<option>...]
    rad patch show <patch-id> [<option>...]
    rad patch diff <patch-id> [<option>...]
    rad patch archive <patch-id> [--undo] [<option>...]
@@ -135,6 +135,7 @@ List options
        --open                 Show only open patches (default)
        --draft                Show only draft patches
        --authored             Show only patches that you have authored
+
        --commented <did>      Show only patches that someone has commented on
        --author <did>         Show only patched where the given user is an author
                               (may be specified multiple times)

@@ -208,6 +209,14 @@ pub struct LabelOptions {
    pub delete: BTreeSet<Label>,
}

+
/// Command line "--commented" argument.
+
#[derive(Default, Debug, PartialEq, Eq)]
+
pub enum Commenter {
+
    #[default]
+
    Me,
+
    Peer(Did),
+
}
+

#[derive(Debug)]
pub enum Operation {
    Show {
@@ -341,6 +350,7 @@ pub struct Options {
    pub quiet: bool,
    pub authored: bool,
    pub authors: Vec<Did>,
+
    pub commenters: Vec<Commenter>,
}

impl Args for Options {
@@ -353,6 +363,7 @@ impl Args for Options {
        let mut quiet = false;
        let mut authored = false;
        let mut authors = vec![];
+
        let mut commenters = vec![];
        let mut announce = true;
        let mut patch_id = None;
        let mut revision_id = None;
@@ -639,6 +650,14 @@ impl Args for Options {
                Long("author") if op == Some(OperationName::List) => {
                    authors.push(term::args::did(&parser.value()?)?);
                }
+
                Long("commented") if op == Some(OperationName::List) => {
+
                    if let Ok(val) = parser.value() {
+
                        let peer = term::args::did(&val)?;
+
                        commenters.push(Commenter::Peer(peer));
+
                    } else {
+
                        commenters.push(Commenter::Me);
+
                    }
+
                }

                // Cache options.
                Long("storage") if op == Some(OperationName::Cache) => {
@@ -829,6 +848,7 @@ impl Args for Options {
                announce,
                authored,
                authors,
+
                commenters,
            },
            vec![],
        ))
@@ -856,7 +876,20 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
            if options.authored {
                authors.insert(profile.did());
            }
-
            list::run(filter.as_ref(), authors, &repository, &profile)?;
+
            list::run(
+
                filter.as_ref(),
+
                authors,
+
                options
+
                    .commenters
+
                    .iter()
+
                    .map(|c| match c {
+
                        Commenter::Me => profile.did(),
+
                        Commenter::Peer(did) => *did,
+
                    })
+
                    .collect(),
+
                &repository,
+
                &profile,
+
            )?;
        }
        Operation::Show {
            patch_id,
modified crates/radicle-cli/src/commands/patch/list.rs
@@ -20,6 +20,7 @@ use itertools::Itertools as _;
pub fn run(
    filter: Option<&patch::Status>,
    authors: BTreeSet<Did>,
+
    commenters: Vec<Did>,
    repository: &Repository,
    profile: &Profile,
) -> anyhow::Result<()> {
@@ -44,6 +45,12 @@ pub fn run(
                continue;
            }
        }
+

+
        if !commenters.is_empty() {
+
            if !commenters.iter().any(|c| patch.has_comment_by(*c)) {
+
                continue;
+
            }
+
        }
        all.push((id, patch));
    }