diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-04-24 13:59:49 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-02-23 17:23:48 +0100 |
commit | 01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91 (patch) | |
tree | f815e506e192f22472cdb1c4c4b286cf6e1ee24b | |
download | git-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.tar.gz git-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.tar.xz git-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.zip |
Initial commit of git-merge-pr
-rwxr-xr-x | git-merge-pr | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/git-merge-pr b/git-merge-pr new file mode 100755 index 0000000..07a8386 --- /dev/null +++ b/git-merge-pr @@ -0,0 +1,23 @@ +#!/bin/sh +# git merge-pr PRNUM[@REMOTE] [GIT-AM FLAGS...] - apply GitHub pull request from command-line +set -e + +PR=${1?no pull request given} +REMOTE= +case "$PR" in +*@*) + REMOTE=${PR#*@} + PR=${PR%%@*};; +esac +shift + +URL=$(git ls-remote --get-url $REMOTE) + +PROJECT=${URL%.git} +PROJECT=${PROJECT##*:} +PROJECT=${PROJECT#//github.com/} + +PATCH=$(mktemp) +trap "rm -f $PATCH" INT TERM EXIT +wget -nv -O "$PATCH" https://github.com/$PROJECT/pull/$PR.patch +git am "$@" "$PATCH" |