diff options
author | Érico Rolim <erico.erc@gmail.com> | 2020-06-22 02:32:38 -0300 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-06-22 13:52:51 +0200 |
commit | 4759da4e208f3c9918862486ff0d7f870314c0cd (patch) | |
tree | 4b7878f675e925005548f62aa250bd1b9660687f | |
parent | 319685958fd7e4475770f79828c5e4c220b76467 (diff) | |
download | git-merge-pr-4759da4e208f3c9918862486ff0d7f870314c0cd.tar.gz git-merge-pr-4759da4e208f3c9918862486ff0d7f870314c0cd.tar.xz git-merge-pr-4759da4e208f3c9918862486ff0d7f870314c0cd.zip |
Support curl, auto detect which one to use.
Closes: #2 [via git-merge-pr]
-rwxr-xr-x | git-merge-pr | 15 |
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" |