Open FrancisGauthier opened 3 years ago
Seconded. This is still the case.
You can pass the path to the solution using the entry
arguments, modifying the dotnet format
command to your needs:
- repo: local
hooks:
#Use dotnet format already installed on your machine
- id: dotnet-format
name: dotnet-format
language: system
entry: dotnet format src/solution.sln -v normal --include
files: ^src/.*
types_or: ["c#", "vb"]
I case you have several solutions in your repository, you can add several hooks with the files
filter, each one running against a particular solution file
- repo: local
hooks:
#Use dotnet format already installed on your machine
- id: dotnet-format
name: dotnet-format
language: system
entry: dotnet format src/project1/solution.sln -v normal --include
files: ^src/project1/.*
types_or: ["c#", "vb"]
- id: dotnet-format
name: dotnet-format
language: system
entry: dotnet format src/project2/solution.sln -v normal --include
files: ^src/project2/.*
types_or: ["c#", "vb"]
This way files from src/project1/
will be checked with dotnet format src/project1/solution.sln
and files from src/project2/
will be checked with dotnet format src/project2/solution.sln
$ git commit src/project1/MyApp/Test.cs
dotnet-format............................................................Passed
dotnet-format........................................(no files to check)Skipped
i use the following .pre-commit-config.yaml file.
The structure of the repository looks like this
repo
The original repo used to pass solutions from a subdirectory. Looks like it is not possible to pass the solution in an argument with this hook. I get the following error saying that there is no solution found in the directory
Thanks,