From d521562c37540dd0e4048d507968e1bd10d03291 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 11 Oct 2022 18:57:06 +0400 Subject: [PATCH] Add script to pr review --- scripts/pr-review.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/pr-review.sh diff --git a/scripts/pr-review.sh b/scripts/pr-review.sh new file mode 100755 index 000000000..15384fad4 --- /dev/null +++ b/scripts/pr-review.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# Checking a pr using hub + +set -e + +require() { + if [[ -z $(command -v "$1" 2>/dev/null) ]]; then + echo " 🛑 Please install $1 and try again" + exit 1 + fi +} + +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 + +pr_id="$(echo "$prd" | awk '{print $1}')" + +gh pr view "$pr_id" --json "files" | jq -r '.files|map(.path)|.[]' +gh pr checkout "$pr_id"