From 335b7bfea616447940bf7086fe0fa95984928be3 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 11 Oct 2022 19:46:40 +0400 Subject: [PATCH] Update PR review script --- scripts/pr-review.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/pr-review.sh b/scripts/pr-review.sh index 15384fad4..2ef18e1ce 100755 --- a/scripts/pr-review.sh +++ b/scripts/pr-review.sh @@ -15,10 +15,16 @@ require jq require gh require fzf -prd="$(gh pr list --json 'number,title' | jq -r '.[]| [.number, .title] | @sh' | column -t -s"'" | fzf)" -[ -z "$prd" ] && echo "No PR selected" && exit 0 +# get the list of open pull requests +prs=$(gh pr list --json number,title --limit 100 | jq -r '.[] | "\(.number) \(.title)"') -pr_id="$(echo "$prd" | awk '{print $1}')" +# select a pr +pr=$(echo "$prs" | fzf --prompt="Select a PR: " --height=50% --reverse --preview="gh pr view {1} --json 'files' | jq -r '.files|map(.path)|.[]'") -gh pr view "$pr_id" --json "files" | jq -r '.files|map(.path)|.[]' -gh pr checkout "$pr_id" +# get the pr number +pr_number=$(echo "$pr" | awk '{print $1}') + +[ -z "$pr_number" ] && echo "🛑 No PR selected" && exit 1 + +echo "Checkout PR: $pr_number" +gh pr checkout "$pr_number"