From 1ded0d8c7109d7e8a6cc7babe2f7c590dd5f2fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Wed, 6 Jul 2022 15:46:10 +0200 Subject: [PATCH] only check staged content --- xtask/src/pre-commit.sh | 16 +++++++++++++++- xtask/src/pre-push.sh | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/xtask/src/pre-commit.sh b/xtask/src/pre-commit.sh index 5b974c7ea..e68b9451f 100755 --- a/xtask/src/pre-commit.sh +++ b/xtask/src/pre-commit.sh @@ -1,2 +1,16 @@ #!/usr/bin/env bash -cargo xtask check --verbose +set -ex + +tf=$(mktemp -t stash.XXX.$$) + +cleanup() { + git apply --whitespace=nowarn < "$tf" && git stash drop -q + rm "$tf" +} + +git diff --full-index --binary > "$tf" +git stash -q --keep-index + +trap cleanup EXIT + +cargo xtask check --verbose \ No newline at end of file diff --git a/xtask/src/pre-push.sh b/xtask/src/pre-push.sh index eb2cd59e9..504c6ebb7 100755 --- a/xtask/src/pre-push.sh +++ b/xtask/src/pre-push.sh @@ -1,2 +1,18 @@ #!/usr/bin/env bash +set -ex + +tf=$(mktemp -t stash.XXX.$$) + +cleanup() { + git apply --whitespace=nowarn < "$tf" && git stash drop -q + rm "$tf" +} + +git diff --full-index --binary > "$tf" +git stash -q --keep-index + +trap cleanup EXIT + cargo xtask test --verbose + +