From 4aa88c0ed4eaf524cec5b6df72cb65045a36c658 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..1a7c82d24 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 --allow-empty --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..5a889b553 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 --allow-empty --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 + +