Last active
February 22, 2021 22:02
-
-
Save RageCage64/b5aa2d49c0ca44382f997078be6bb8f0 to your computer and use it in GitHub Desktop.
Apply all dependabot PRs in a single branch
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
tmp_dir_name="dbot_patches" | |
mkdir -p $tmp_dir_name | |
base_branch=$1 | |
if [ -z "$base_branch" ] ; then | |
base_branch="master" | |
fi | |
dependabot_branches=( `git branch -r | grep origin/dependabot/` ) | |
today=$(date +'%d%m%Y') | |
git checkout -b dependabot_$today | |
for branch in "${dependabot_branches[@]}" | |
do | |
echo "$branch" | |
patch_file_name=$(echo "$branch" | sed "s/\///g") | |
patch_file_name="$patch_file_name.patch" | |
git diff $base_branch $branch > $tmp_dir_name/$patch_file_name | |
git apply --reject --whitespace=fix $tmp_dir_name/$patch_file_name | |
done | |
rm -rf $tmp_dir_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script will apply all Dependabot branches from the remote into a single branch. It makes two assumptions:
This script was written to avoid the pain caused by applying Dependabot PRs one at a time.