Wait for all PR checks to pass, then squash-merge and clean up.
Wait for all CI checks to pass on the current pull request, then squash-merge it and clean up.
If the user provided a PR number as $ARGUMENTS, use that. Otherwise, detect the PR for the current branch:
gh pr view --json number,title,url,headRefName,state
If no PR is found or the PR is already merged/closed, inform the user and stop.
Poll the PR's check status:
gh pr checks {number} --json name,state,conclusion
state == "SUCCESS" or state == "SKIPPED", proceed to Step 3.state == "FAILURE", inform the user which check(s) failed and stop. Do NOT merge.state == "PENDING", wait 30 seconds and poll again.Squash-merge the PR and delete the remote branch:
gh pr merge {number} --squash --delete-branch
If the merge fails (e.g. due to merge conflicts), inform the user and stop.
git checkout main && git pull
If the local branch still exists, delete it:
git branch -d {branch_name}
Ignore errors if the branch was already deleted.
Let the user know: