about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xgit-merge-pr15
1 files changed, 13 insertions, 2 deletions
diff --git a/git-merge-pr b/git-merge-pr
index 2d11511..03259b7 100755
--- a/git-merge-pr
+++ b/git-merge-pr
@@ -16,8 +16,19 @@ PROJECT=${URL%.git}
 PROJECT=${PROJECT##*:}
 PROJECT=${PROJECT#//github.com/}
 
+if command -v wget >/dev/null; then
+	API_CMD="wget -q -O --header"
+	PATCH_CMD="wget -nv -O"
+elif command -v curl >/dev/null; then
+	API_CMD="curl -s -H"
+	PATCH_CMD="curl -Lo"
+else
+	echo "Neither wget or curl could be found in PATH"
+	exit 1
+fi
+
 if [ -z "$PR" ]; then
-	wget -q -O- --header 'Accept: application/json' \
+	$API_CMD 'Accept: application/json' \
 		"https://api.github.com/repos/${PROJECT}/pulls" |
 		jq -r 'if length > 0
 			then reverse[] | "\(.number) <\(.user.login)> \(.title)"
@@ -29,7 +40,7 @@ fi
 
 PATCH="$(mktemp)"
 trap "rm -f $PATCH" INT TERM EXIT
-wget -nv -O "$PATCH" https://github.com/$PROJECT/pull/"$PR".patch
+$PATCH_CMD "$PATCH" https://github.com/$PROJECT/pull/"$PR".patch
 WHITESPACE="$(git config --get merge-pr.whitespace || true)"
 git am "--whitespace=${WHITESPACE:-warn}" "$@" "$PATCH"