From fc27042c0b8d6e58f699f3839c17fd2653306aa4 Mon Sep 17 00:00:00 2001 From: karitham Date: Tue, 22 Sep 2026 15:15:36 +0200 Subject: [PATCH] pkgs/gh-prc: allow per-review filtering --- pkgs/gh-prc/gh-prc.nu | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/gh-prc/gh-prc.nu b/pkgs/gh-prc/gh-prc.nu index cc66331..71e2b31 100644 --- a/pkgs/gh-prc/gh-prc.nu +++ b/pkgs/gh-prc/gh-prc.nu @@ -3,8 +3,9 @@ # PR: explicit reference (URL, owner/repo#123, or number), or inferred from the # closest bookmarked ancestor of @ via jj. Comments print as `path:line` so # the location opens directly in helix. Roots print `thread `, replies -# `# (thread )`; --thread shows one thread by any visible id. -# Resolved threads are hidden unless --all. +# `# (thread )`; --thread shows one thread by any visible id, and +# --review keeps only threads rooted in one review (their replies stay visible +# even when posted by another review). Resolved threads are hidden unless --all. def run-json [ctx: closure]: nothing -> any { @@ -265,6 +266,7 @@ def main [ --resolved # Only comments in resolved threads --outdated # Only outdated comments --thread (-t): int # Only the thread containing comment (a root id or any reply id in it; implies --all) + --review (-r): int # Only threads whose top-level comment belongs to review (all their replies stay visible) ] { let ref = ( if ($pr | is-empty) { resolve-ref } else { resolve-ref ($pr | str join " ") } @@ -288,6 +290,7 @@ def main [ resolved: $resolved show_all: ($all or ($thread != null)) thread: $thread + review: $review } let threads = ( build-threads ($data.reviews.nodes | each {|r| $r.comments.nodes } | flatten) $resolved_ids @@ -298,7 +301,12 @@ def main [ let wanted = (format-states $state) let reviews = ($data.reviews.nodes - | where {|r| ($wanted | is-empty) or ($r.state in $wanted) } + | where {|r| + ( + (($wanted | is-empty) or ($r.state in $wanted)) + and (($review == null) or ($r.databaseId == $review)) + ) + } | each {|r| let owned = $threads | where {|t| $t.review == $r.databaseId } { @@ -333,6 +341,12 @@ def main [ } else { print $"no thread matches ($flt.thread)" } + } else if $review != null { + if ($data.reviews.nodes | any {|r| $r.databaseId == $review }) { + print $"review ($review) hidden by filters" + } else { + print $"no review matches ($review)" + } } else { print "(no reviews)" } -- 2.51.2