Skip to content

Commit

Permalink
workflows/check-nix-format: Only ensure for already formatted files
Browse files Browse the repository at this point in the history
This prevents situations where contributors need to suddenly format a
huge file even if they only changed a small part of it (e.g.
all-packages.nix)
  • Loading branch information
infinisil committed Jul 17, 2024
1 parent 8f4eca4 commit 8bbfb0b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/check-nix-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,26 @@ jobs:
file=${entry[1]}
case $type in
A*)
source=""
dest=$file
;;
M*)
source=$file
dest=$file
;;
C*|R*)
source=$file
read -r -d '' dest
;;
*)
echo "Ignoring file $file with type $type"
continue
esac
if ! nixfmt --check "$dest"; then
# Ignore files that weren't already formatted
if [[ -n "$source" ]] && ! nixfmt --check ${{ env.base }}/"$source" 2>/dev/null; then
echo "Ignoring file $file because it's not formatted in the base commit"
elif ! nixfmt --check "$dest"; then
unformattedFiles+=("$file")
fi
done < <(git diff -z --name-status ${{ env.baseRev }} -- '*.nix')
Expand Down

0 comments on commit 8bbfb0b

Please sign in to comment.