summaryrefslogtreecommitdiff
path: root/git-fetch-pr
blob: 6b3a80c49dd2b17f77bc6c85e582591aea8bff1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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|')