Skip to content

Instantly share code, notes, and snippets.

@bbarenblat
Created June 1, 2020 14:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bbarenblat/3efd1e3ecbba7b886a6cc9faa3236363 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Copyright 2019 Google LLC
# SPDX-License-Identifier: Apache-2.0
set -e
if [ $# -ne 1 ]; then
cat >&2 <<EOF
usage: git fetch-pr https://github.com/[repo]/pull/[number]
EOF
exit 129
fi
exec git fetch $(
echo "$1" |
sed -E 's|^https?://(www\.)?github.com/([^/]+)/([^/]+)/pull/([^/]+).*|https://github.com/\2/\3 refs/pull/\4/head|')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment