Skip to content

Instantly share code, notes, and snippets.

@carlocab
Created August 25, 2022 17:00
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 carlocab/6576556282d776a3f66de4203d7f4869 to your computer and use it in GitHub Desktop.
Save carlocab/6576556282d776a3f66de4203d7f4869 to your computer and use it in GitHub Desktop.
Rebase failing PRs.
#!/bin/bash
LIMIT=250
CLOSE_MESSAGE="please reopen against master"
failed_prs="$(gh pr list --limit $LIMIT --search 'status:failure' | cut -f1)"
git fetch origin
for pr in $failed_prs
do
gh pr checkout "$pr"
if ! git rebase origin/master
then
git rebase --abort
gh pr close "$pr" --comment "$CLOSE_MESSAGE"
elif ! git push --force-with-lease
then
gh pr close "$pr" --comment "$CLOSE_MESSAGE"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment