Created
June 5, 2016 10:45
-
-
Save jow-/cd0127746cca14d2a7c4622706604b54 to your computer and use it in GitHub Desktop.
A script to convert pull requests into patch files for git-am
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/sh | |
REPO=$1 | |
PR=$2 | |
PATCH=$3 | |
URIS=$(curl -s https://api.github.com/repos/$REPO/pulls/$PR/commits | sed -ne 's|^.*"html_url": "\(.*/commit/.*\)",|\1.patch|p') | |
i=1 | |
for uri in $URIS; do | |
filename=$(printf pr_%i_%03i.patch $PR $i) | |
if [ -z "$PATCH" -o "$i" = "$PATCH" ]; then | |
echo $filename | |
curl -s -o $filename $uri | |
fi | |
i=$((i + 1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment