From 32ccb30d31dafb0b3fd7c42a43d6f469bf7f9c8c Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Mon, 14 Dec 2020 19:06:48 +0100 Subject: [PATCH] Make pre-commit hook work for non-terminal environments --- hooks/pre-commit.hook | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook index a367c2c9..92db1337 100755 --- a/hooks/pre-commit.hook +++ b/hooks/pre-commit.hook @@ -19,6 +19,13 @@ install_rustfmt() { if ! which cargo &> /dev/null || ! cargo fmt --help &> /dev/null; then echo "Can't check Fractal's code style, because rustfmt could not be run." + + if [ ! -t 1 ]; then + # No input is possible + echo "Performing commit." + exit 0 + fi + echo "" echo "y: Install rustfmt via rustup" echo "n: Don't install rustfmt and perform the commit"