From 01e6b69543325cfae2fd0f33b3c6b8e7f3d13a91 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Fri, 24 Apr 2015 13:59:49 +0200 Subject: Initial commit of git-merge-pr --- git-merge-pr | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 git-merge-pr 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" -- cgit 1.4.1