-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fixes #27632][Infrastructure] Added dotnet-format pre commit hook to…
… run dotnet-format on changed files * Added pre-commit hook to format changed source files. * Added code to build script to check dotnet-format tool installation. * Configure default git hooks directory to .githooks to version and track hooks.
- Loading branch information
1 parent
461c08b
commit eadca9d
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
LC_ALL=C | ||
|
||
# Select files to format | ||
FILES=$(git show --name-only --pretty="") | ||
[ -z "$FILES" ] && exit 0 | ||
|
||
# Format all selected files with dotnet-format | ||
echo "dotnet-format: Formatting changed source files.." | ||
echo "$FILES" | cat | xargs | sed -e 's/ /,/g' | xargs dotnet-format --folder . --include >/dev/null | ||
echo "dotnet-format: $(git diff --cached --numstat | wc -l) file(s) formatted." | ||
|
||
# Add files to staging | ||
echo "$FILES" | xargs git add | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters