Last active
December 6, 2023 09:34
-
-
Save eps1lon/960f3b575dc2ffeff5c04206069906af to your computer and use it in GitHub Desktop.
Split branch into one branch per folder
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
#!/bin/bash | |
set -e | |
branchToSplit="feat/react/deprecated-react-node-array" | |
title="Remove usage of deprecated ReactChild" | |
message="This PR removes the usage of the deprecated \`ReactChild\` type (see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/64451)." | |
mergeBase=$(git merge-base origin/master $branchToSplit) | |
types=( $(git diff --name-only $mergeBase $branchToSplit | grep -oE 'types/[^/]+/' | cut -d/ -f2 | uniq) ) | |
for type in "${types[@]}"; do | |
echo "Splitting $type" | |
branchName="$branchToSplit-split/$type" | |
git checkout -b "$branchName" master | |
git checkout "$branchToSplit" -- "types/$type" | |
prTitle="[$type] $title" | |
git commit -a -m "$prTitle" | |
git push -u origin HEAD | |
gh pr create \ | |
--title "$prTitle" \ | |
--body "$message"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment