Skip to content

Instantly share code, notes, and snippets.

@PaulTaykalo
Created November 6, 2023 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulTaykalo/5476016a46bfcdea82ad9d3952688491 to your computer and use it in GitHub Desktop.
Save PaulTaykalo/5476016a46bfcdea82ad9d3952688491 to your computer and use it in GitHub Desktop.
Re-request all Revieers Again
function re_request_reviews {
# Get the details of latest reviews
local latest_reviews=$(gh pr view --json latestReviews -q '.latestReviews[] | select(.state != "APPROVED") | .author.login')
# Create an empty string variable to aggregate the reviewer list
local reviewers=""
# Loop through the list of reviewers who haven't approved and add each one to the reviewer list
for reviewer in $latest_reviews; do
echo "Adding $reviewer to re-request list"
# Append each reviewer to the string
reviewers="$reviewers,$reviewer"
done
# Remove the leading comma from the string
reviewers=${reviewers#,}
# Check if the reviewers string is empty
if [ -z "$reviewers" ]
then
echo "Error: There are no reviewers to re-request."
return 1
fi
# Re-request reviews using the aggregated reviewer list
echo "Re-requesting reviews from: $reviewers"
gh pr edit --add-reviewer $reviewers
echo "Review re-request has been sent."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment