2016-10-11 20:36:54 +02:00
|
|
|
#!/bin/bash
|
2015-12-13 02:06:59 +01:00
|
|
|
set -e
|
|
|
|
|
2017-04-12 04:07:17 +02:00
|
|
|
if ! git diff-index --quiet HEAD; then
|
|
|
|
set +x
|
2017-05-08 19:51:59 +02:00
|
|
|
echo "There are uncommitted changes:"
|
|
|
|
git status --short
|
|
|
|
echo "Doing nothing to avoid losing your work."
|
2017-04-12 04:07:17 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-06-22 02:25:49 +02:00
|
|
|
|
|
|
|
remote_default="$(git config zulip.zulipRemote || echo upstream)"
|
2018-07-28 07:25:57 +02:00
|
|
|
pseudo_remote="$(git config zulip.prPseudoRemote || echo)"
|
2018-06-22 02:25:49 +02:00
|
|
|
|
2015-12-13 02:06:59 +01:00
|
|
|
request_id="$1"
|
2018-06-22 02:25:49 +02:00
|
|
|
remote=${2:-"$remote_default"}
|
|
|
|
|
2018-07-28 07:25:57 +02:00
|
|
|
if [ -z "$pseudo_remote" ]; then
|
|
|
|
set -x
|
|
|
|
git fetch "$remote" "pull/$request_id/head"
|
|
|
|
git reset --hard FETCH_HEAD
|
|
|
|
else
|
|
|
|
target_ref=refs/remotes/"$pseudo_remote"/"$request_id"
|
|
|
|
set -x
|
2018-08-03 02:14:50 +02:00
|
|
|
git fetch "$remote" +"pull/$request_id/head:$target_ref"
|
2018-07-28 07:25:57 +02:00
|
|
|
git reset --hard "$target_ref"
|
|
|
|
fi
|