Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-addons: add a script to help fetch pull requests from GitHub
- Loading branch information
1 parent
a9fbc95
commit 5808966
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |