mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
As described in the commit that added this function, this fixes one quite annoying bug and one at least in-principle bug: * On Windows, the simple version (lacking `git update-index --refresh`) routinely gives false positives, making the tools that rely on it basically unusable. * If you have uncommitted changes in the index but manage to have the worktree nevevertheless match HEAD, the simple version will give a false negative and we'd blow away those changes.
18 lines
396 B
Bash
Executable File
18 lines
396 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
this_file=$(readlink -f "${BASH_SOURCE[0]}")
|
|
# shellcheck source=lib/git-tools.bash
|
|
. "${this_file%/*}"/lib/git-tools.bash
|
|
|
|
require_clean_work_tree 'check out PR as branch'
|
|
|
|
request_id="$1"
|
|
remote=${2:-"upstream"}
|
|
|
|
set -x
|
|
git fetch "$remote" "pull/$request_id/head"
|
|
git checkout -B "review-${request_id}" "$remote/master"
|
|
git reset --hard FETCH_HEAD
|
|
git pull --rebase
|