Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active March 24, 2025 22:08
Show Gist options
  • Save lmmx/96490cb48b8520d01c0b565bb9acdc1c to your computer and use it in GitHub Desktop.
Save lmmx/96490cb48b8520d01c0b565bb9acdc1c to your computer and use it in GitHub Desktop.
Merge all dependency bot PRs (e.g. pre-commit)
PR_CMDS=$(gh search prs --limit 100 --owner $(gh api user -q '.login') --author pre-commit-ci[bot] --state open --json repository,number | jq -r '.[] | "gh pr merge \(.number) -R \(.repository.nameWithOwner) -s -d"' | awk '{printf "%s%s", (NR==1 ? "" : " && \n"), $0} END{print ""}'); echo "$PR_CMDS"; eval "$PR_CMDS"
PR_CMDS=$(
gh search prs \
--limit 100 \
--owner $(gh api user -q '.login') \
--author pre-commit-ci[bot] \
--state open \
--json repository,number |
jq -r '.[] | "gh pr merge \(.number) -R \(.repository.nameWithOwner) -s -d"' |
awk '{printf "%s%s", (NR==1 ? "" : " && \n"), $0} END{print ""}'
)
echo "$PR_CMDS"
eval "$PR_CMDS"
@lmmx
Copy link
Author

lmmx commented Mar 18, 2025

Example output:

gh pr merge 4 -R lmmx/pydanttention -s -d && 
gh pr merge 6 -R lmmx/chinois -s -d && 
gh pr merge 14 -R lmmx/campbells -s -d && 
gh pr merge 6 -R lmmx/botodto -s -d && 
gh pr merge 18 -R lmmx/bisque -s -d && 
gh pr merge 2 -R lmmx/fieldrouter -s -d && 
gh pr merge 5 -R lmmx/aws-step-functions-pydantic -s -d && 
gh pr merge 7 -R lmmx/classipypi -s -d && 
gh pr merge 6 -R lmmx/wikitransp -s -d && 
gh pr merge 1 -R lmmx/sphinx-type-annotations-demo -s -d

(Which is then immediately executed and prints:)

✓ Squashed and merged pull request lmmx/pydanttention#4 (chore(pre-commit): autoupdate hooks)
✓ Deleted remote branch pre-commit-ci-update-config
✓ Squashed and merged pull request lmmx/chinois#6 (chore(pre-commit): autoupdate hooks)
✓ Deleted remote branch pre-commit-ci-update-config
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment