no need to auto format if there is no change

This commit is contained in:
Ranomier 2025-01-01 15:15:11 +01:00
parent 5fa380223b
commit e70b8beb7c

View file

@ -24,11 +24,15 @@ exit_with_new_shell() {
cd "$PROJECT" || exit 1 cd "$PROJECT" || exit 1
nvim nvim
# check if there are changes at all
[[ -z "$(git diff -U0 "$GIT_PATTERN")" ]] && echo ">>> no changes, exiting ..." && exit_with_new_shell
# only then do auto formating
printf ">>> auto formating ..." printf ">>> auto formating ..."
nix fmt . &> /dev/null nix fmt . &> /dev/null
printf " DONE!\n" printf " DONE!\n"
[[ -z "$(git diff -U0 "$GIT_PATTERN")" ]] && echo ">>> no changes, exiting ..." && exit_with_new_shell # and then show the user a diff
git diff -U0 "$GIT_PATTERN" # as a seperate command so we get nice colors and pager git diff -U0 "$GIT_PATTERN" # as a seperate command so we get nice colors and pager
printf ">>> Do you want to rebuild NixOS? [y/N]\n" printf ">>> Do you want to rebuild NixOS? [y/N]\n"