1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-01-17 22:28:32 +01:00

Script to review prs

This commit is contained in:
Kamran Ahmed 2022-10-11 19:29:37 +04:00
parent 26d337c277
commit 0ba067e9a0
2 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,7 @@
"private": true, "private": true,
"license": "BSD-4-Clause", "license": "BSD-4-Clause",
"scripts": { "scripts": {
"review": "./scripts/pr-review.sh",
"dev": "next", "dev": "next",
"serve:out": "serve out", "serve:out": "serve out",
"build": "./scripts/build.sh", "build": "./scripts/build.sh",

View File

@ -15,10 +15,15 @@ require jq
require gh require gh
require fzf require fzf
prd="$(gh pr list --json 'number,title' | jq -r '.[]| [.number, .title] | @sh' | column -t -s"'" | fzf)" # get the list of open pull requests
[ -z "$prd" ] && echo "No PR selected" && exit 0 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)|.[]' # get the pr number
gh pr checkout "$pr_id" pr_number=$(echo "$pr" | awk '{print $1}')
[ -z "$pr_number" ] && echo "🛑 No PR selected" && exit 1
gh pr checkout "$pr_number"