Skip to content

Commit

Permalink
git-addons: add a script to help fetch pull requests from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
jszakmeister committed Mar 23, 2014
1 parent a9fbc95 commit 5808966
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions git-addons/git-fetch-pull-request
@@ -0,0 +1,38 @@
#!/bin/sh
# Copyright (c) 2012, John Szakmeister <john@szakmeister.net>
#
# Idea was taken from here, but extended:
# <https://community.jboss.org/blogs/stuartdouglas/2011/09/06/merging-github-pull-requests>

die () {
echo >&2 "ERROR: $*"
exit 1
}

find_upstream() {
for up in "upstream" "origin"
do
git config --local remote.$up.url >& /dev/null
if test $? -eq 0; then
echo $up
return 0
fi
done

die "No upstream or origin remote. " \
"Can't determine where to fetch pull requests"
}

pull () {
upstream=$(find_upstream)

cmd="git fetch $upstream "
for var in "$@"
do
cmd="$cmd pull/$var/head:pr-$var"
done

$cmd || die "Could not fetch all the pull requests."
}

pull "$@"

0 comments on commit 5808966

Please sign in to comment.