Browse Source

Automatically install dotnet-format in specific version in the commit hook.

pull/2749/head
Daniel Grunwald 3 years ago
parent
commit
fc882b9203
  1. 14
      BuildTools/pre-commit
  2. 2
      README.md

14
BuildTools/pre-commit

@ -1,10 +1,20 @@
#!/bin/sh #!/bin/sh
# #
# To enable this hook, copy/symlink this file to ".git/hooks/pre-commit". # To enable this hook, copy/symlink this file to ".git/hooks/pre-commit".
# mklink .git\hooks\pre-commit ..\..\BuildTools\pre-commit
set -eu
DOTNET_FORMAT_VERSION=6.2.315104
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION"
if [ ! -d "$DOTNET_PATH" ]; then
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json"
fi
"$DOTNET_PATH/dotnet-format.exe" --version
#if git diff --quiet --ignore-submodules; then #if git diff --quiet --ignore-submodules; then
# dotnet format whitespace --no-restore --verbosity detailed ILSpy.sln # "$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
# git add -u -- \*\*.cs # git add -u -- \*\*.cs
#else #else
exec dotnet format whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln exec "$DOTNET_PATH/dotnet-format.exe" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln
#fi #fi

2
README.md

@ -81,7 +81,7 @@ How to contribute
----------------- -----------------
- Report bugs - Report bugs
- If you want to contribute a pull request, please add https://gist.github.com/siegfriedpammer/75700ea61609eb22714d21885e4eb084 to your `.git/hooks` to prevent checking in code with wrong indentation. We use tabs and not spaces. The build server runs the same script, so any pull requests using wrong indentation will fail. - If you want to contribute a pull request, please add https://github.com/icsharpcode/ILSpy/blob/master/BuildTools/pre-commit to your `.git/hooks` to prevent checking in code with wrong formatting. We use tabs and not spaces. The build server runs the same script, so any pull requests using wrong formatting will fail.
Current and past [contributors](https://github.com/icsharpcode/ILSpy/graphs/contributors). Current and past [contributors](https://github.com/icsharpcode/ILSpy/graphs/contributors).

Loading…
Cancel
Save