diff --git a/tools/fetch-pull-request b/tools/fetch-pull-request index f85640001c..d23b34f774 100755 --- a/tools/fetch-pull-request +++ b/tools/fetch-pull-request @@ -1,12 +1,11 @@ #!/usr/bin/env bash set -e -if ! git diff-index --quiet HEAD; then - echo "There are uncommitted changes:" - git status --short - echo "Doing nothing to avoid losing your work." - exit 1 -fi +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"} diff --git a/tools/fetch-rebase-pull-request b/tools/fetch-rebase-pull-request index 4711f6cb1b..115f61d9d8 100755 --- a/tools/fetch-rebase-pull-request +++ b/tools/fetch-rebase-pull-request @@ -1,12 +1,11 @@ #!/usr/bin/env bash set -e -if ! git diff-index --quiet HEAD; then - echo "There are uncommitted changes:" - git status --short - echo "Doing nothing to avoid losing your work." - exit 1 -fi +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"} diff --git a/tools/reset-to-pull-request b/tools/reset-to-pull-request index abe1f2a4f7..e525b94e13 100755 --- a/tools/reset-to-pull-request +++ b/tools/reset-to-pull-request @@ -39,13 +39,11 @@ if [ -z "$request_id" ]; then usage fi -if ! git diff-index --quiet HEAD; then - set +x - echo "There are uncommitted changes:" - git status --short - echo "Doing nothing to avoid losing your work." - exit 1 -fi +this_file=$(readlink -f "${BASH_SOURCE[0]}") +# shellcheck source=lib/git-tools.bash +. "${this_file%/*}"/lib/git-tools.bash + +require_clean_work_tree 'reset to PR' if [ -z "$pseudo_remote" ]; then set -x