1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-22 23:51:39 +03:00

Merge pull request #480 from amarshall/fix-git-hook

devos: Fix editorconfig Git hook when no files are changed
This commit is contained in:
chris montgomery 2022-07-31 11:19:46 -04:00 committed by GitHub
commit c8eb0a6388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,13 +14,16 @@ nix_files=($($diff -- '*.nix'))
all_files=($($diff))
# Format staged nix files.
if [[ -n "${nix_files[@]}" ]]; then
if (( ${#nix_files[@]} != 0 )); then
nixpkgs-fmt "${nix_files[@]}" \
&& git add "${nix_files[@]}"
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" \