about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-04-24 13:59:49 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-02-23 17:23:48 +0100
commit01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91 (patch)
treef815e506e192f22472cdb1c4c4b286cf6e1ee24b
downloadgit-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.tar.gz
git-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.tar.xz
git-merge-pr-01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91.zip
Initial commit of git-merge-pr
-rwxr-xr-xgit-merge-pr23
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"