From dd51f64bc5ff2a2127237805d9dcd6bd7ffebfed Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Jul 2022 09:12:06 -0400 Subject: [PATCH] devos: Fix editorconfig Git hook when no files are changed It is possible to make a commit with no files, e.g. with `--allow-empty` or `--only` flags to `git-commit`. Previously, this hook would hang indefinitely in those cases as `editorconfig-checker` with no file arguments will read from stdin. --- examples/devos/shell/hooks/pre-commit.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/devos/shell/hooks/pre-commit.sh b/examples/devos/shell/hooks/pre-commit.sh index 7e3a336..a7fa908 100755 --- a/examples/devos/shell/hooks/pre-commit.sh +++ b/examples/devos/shell/hooks/pre-commit.sh @@ -20,7 +20,10 @@ if (( ${#nix_files[@]} != 0 )); then fi # check editorconfig -editorconfig-checker -- "${all_files[@]}" +if (( ${#all_files[@]} != 0 )); then + editorconfig-checker -- "${all_files[@]}" +fi + if [[ $? != '0' ]]; then printf "%b\n" \ "\nCode is not aligned with .editorconfig" \