mirror of
https://github.com/divnix/digga.git
synced 2025-01-03 22:08:36 +03:00
💡 refactor
Check exit code directly
Eliminated the redundant check for the exit code of `editorconfig-checker`. This way is more explicit and idiomatic. https://github.com/koalaman/shellcheck/wiki/SC2181
This commit is contained in:
parent
f8ec6efba4
commit
aa7dc0e6c3
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
@ -14,19 +13,17 @@ nix_files=($($diff -- '*.nix'))
|
||||
all_files=($($diff))
|
||||
|
||||
# Format staged nix files.
|
||||
if (( ${#nix_files[@]} != 0 )); then
|
||||
nixpkgs-fmt "${nix_files[@]}" \
|
||||
&& git add "${nix_files[@]}"
|
||||
if ((${#nix_files[@]} != 0)); then
|
||||
nixpkgs-fmt "${nix_files[@]}" &&
|
||||
git add "${nix_files[@]}"
|
||||
fi
|
||||
|
||||
# check editorconfig
|
||||
if (( ${#all_files[@]} != 0 )); then
|
||||
editorconfig-checker -- "${all_files[@]}"
|
||||
fi
|
||||
|
||||
if [[ $? != '0' ]]; then
|
||||
if ((${#all_files[@]} != 0)); then
|
||||
if ! editorconfig-checker -- "${all_files[@]}"; then
|
||||
printf "%b\n" \
|
||||
"\nCode is not aligned with .editorconfig" \
|
||||
"Review the output and commit your fixes" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user