Last active
September 30, 2021 08:01
-
-
Save deniskyashif/6d4ee707efa94b11bc3950856eff5688 to your computer and use it in GitHub Desktop.
Git pre-commit hook to run dotnet format on the staged files.
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
#!/bin/sh | |
cs_files="$(git diff --name-only --cached --diff-filter=d | grep -E '\.cs$')" | |
if [ -n "$cs_files" ]; then | |
cs_files_seperated_by_comma="$(echo $cs_files | tr ' ' ,)" | |
dotnet format --workspace <Project-Root> --files $cs_files_seperated_by_comma | |
git add $cs_files | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good catch, noted, thank you!