Roll up, rollup, get your Dependabot PRs together here
09Mar23
While I wait for GitHub to get their act together on my Dependabot Wishlist I’ve created a little script for my first frustration – rollups.
Another morning, another patch release of Dart, another 4 Dependabot PRs in my inbox:

Only this time I was able to simply run:
rollup.sh 1247 1250
and the subsequent 3 PRs were rolled into the first, which I could then approve, and merge once CI had passed :)
Here’s the script (also on Gist), which depends on having the gh command line tool installed, and that’s run from the root of a clone of the repo concerned (I keep the script itself in ~/.local/bin/, but obviously anywhere on the PATH will be fine):
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage rollup.sh <BASE_PR> <LAST_PR>"
exit 1
fi
BASE_PR=$1
LAST_PR=$2
git pull
gh pr checkout "$BASE_PR"
for (( i=(($BASE_PR + 1)); i<=$LAST_PR; i++ ))
do
PR_BRANCH=$(gh pr view "$i" --json headRefName -q .headRefName)
git merge origin/"$PR_BRANCH" -m "build(deps): Merge branch for #{$i} {$PR_BRANCH}"
done
git push
It would still be nicer to say ‘@dependabot rollup #1247-1250‘ but for now that little script achieves the same outcome.
Filed under: howto, software | Leave a Comment
Tags: bash, Dependabot, dependencies, dependency management, gh, git, github, PR, PRs, rollup, script
No Responses Yet to “Roll up, rollup, get your Dependabot PRs together here”