Created
June 28, 2022 13:27
-
-
Save sblack4/d48c525b2b3fff370781e66ec4b8d857 to your computer and use it in GitHub Desktop.
Copy all the changes from a PR into another branch or repo
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 | |
# clone to copies of the same repo, side by side | |
# add this script to the repo you want to copy from | |
# the name of the repo you want to copy to | |
REPO_NAME="myrepo" | |
# the PR number with the modifications | |
PR_NUMBER="5" | |
gh pr view $PR_NUMBER --json files --jq '.files.[].path' > files-changed.txt | |
while read l; do | |
new_file="../$REPO_NAME/$l" | |
file_path=$(echo $new_file | sed 's%/[^/]*$%%') | |
[ -d $file_path ] || mkdir -p $file_path | |
cp $l $new_file || rm $new_file | |
done <files-changed.txt | |
rm files-changed.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment