From ce92fb9737e96890b39213ddd53acb1522d3daaf Mon Sep 17 00:00:00 2001 From: Sebastien Lebreton Date: Mon, 19 Aug 2024 19:16:25 +0200 Subject: [PATCH 1/2] Format staged C# files on commit --- .config/dotnet-tools.json | 12 ++++++++++ .husky/pre-commit | 22 +++++++++++++++++++ .husky/task-runner.json | 10 +++++++++ .../Microsoft.Unity.Analyzers.csproj | 5 +++++ 4 files changed, 49 insertions(+) create mode 100644 .config/dotnet-tools.json create mode 100644 .husky/pre-commit create mode 100644 .husky/task-runner.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..d2497dd --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "husky": { + "version": "0.7.1", + "commands": [ + "husky" + ] + } + } +} \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..fd85d23 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,22 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +## husky task runner examples ------------------- +## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky' + +## run all tasks +#husky run + +### run all tasks with group: 'group-name' +#husky run --group group-name + +## run task with name: 'task-name' +#husky run --name task-name + +## pass hook arguments to task +#husky run --args "$1" "$2" + +## or put your custom commands ------------------- +#echo 'Husky.Net is awesome!' + +dotnet husky run diff --git a/.husky/task-runner.json b/.husky/task-runner.json new file mode 100644 index 0000000..fffa434 --- /dev/null +++ b/.husky/task-runner.json @@ -0,0 +1,10 @@ +{ + "tasks": [ + { + "name": "dotnet-format-staged-files", + "command": "dotnet", + "args": ["format", "src/Microsoft.Unity.Analyzers.sln", "whitespace", "--verbosity", "quiet", "--include", "${staged}"], + "include": ["**/*.cs"] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj b/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj index 75fce9b..913c1a5 100644 --- a/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj +++ b/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj @@ -28,4 +28,9 @@ + + + + + From 4e099e7c943164b1722abd1d9fc7b7c9c8739ab2 Mon Sep 17 00:00:00 2001 From: Sebastien Lebreton Date: Mon, 19 Aug 2024 19:18:01 +0200 Subject: [PATCH 2/2] Fix path --- src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj b/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj index 913c1a5..d895a61 100644 --- a/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj +++ b/src/Microsoft.Unity.Analyzers/Microsoft.Unity.Analyzers.csproj @@ -30,7 +30,7 @@ - +