Browse Source

Add BuildTools/format.bat

pull/3239/head
Daniel Grunwald 10 months ago
parent
commit
da24b7d126
  1. 3
      BuildTools/format.bat
  2. 7
      BuildTools/pre-commit

3
BuildTools/format.bat

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
@rem This file can be used to trigger the commit hook's formatting,
@rem modifying the local formatting even if not committing all changes.
"%ProgramFiles%\Git\usr\bin\bash.exe" BuildTools\pre-commit --format

7
BuildTools/pre-commit

@ -8,13 +8,18 @@ set -eu @@ -8,13 +8,18 @@ set -eu
DOTNET_FORMAT_VERSION=8.0.453106
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION"
if [ ! -d "$DOTNET_PATH" ]; then
echo "Downloading dotnet-format $DOTNET_FORMAT_VERSION..."
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
fi
"$DOTNET_PATH/dotnet-format.exe" --version
if git diff --quiet --ignore-submodules; then
if [ "${1:-}" = "--format" ]; then
# called via format.bat
"$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
elif git diff --quiet --ignore-submodules; then
"$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln
git add -u -- \*\*.cs
else
echo Partial commit: only verifying formatting
exec "$DOTNET_PATH/dotnet-format.exe" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln
fi

Loading…
Cancel
Save