Created
November 6, 2023 22:46
-
-
Save PaulTaykalo/5476016a46bfcdea82ad9d3952688491 to your computer and use it in GitHub Desktop.
Re-request all Revieers Again
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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