Skip to content

Commit f73d19b

Browse files
committed
Try to avoid dotnet formating changes not in current commit
- formatted files are added into commits even when not intended
1 parent 24883f3 commit f73d19b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.githooks/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22
LC_ALL=C
33

4-
# Select files to format
5-
FILES=$(git show --name-only --pretty="")
4+
# Select files to format, ignoring broken, deleted, unmerged, and unknown files
5+
FILES=$(git show --diff-filter=bdux --name-only --pretty="")
66
[ -z "$FILES" ] && exit 0
77

88
# Format all selected files with dotnet-format
@@ -12,4 +12,4 @@ echo "dotnet-format: $(git diff --cached --numstat | wc -l) file(s) formatted."
1212

1313
# Add files to staging
1414
echo "$FILES" | xargs git add
15-
exit 0
15+
exit 0

0 commit comments

Comments
 (0)