Closed DiegoEstrada closed 2 months ago
Closing this issue as found the reason of why commit is not being validate.
Reviewing code I fount an example to lint commits and you need to use a different hook commit-message
instead of pre-commit
You can do it by runningdotnet husky add commit-message
Then you can refer to the script defined before and it should work
Version
0.6.4
Details
I was setting up the husky in my project to verify that the commit follows the conventional commits. I created a new
tool-manifest
then installed Husky and added somedotnet
commands (build and test). Finally I used the script on your doc to match the regular expression against the current commit. I faced with issues, no mater if the commit followed or not the pattern.After debugging I noticed that the argument passed to the
csx
file is always empty,I am printing the value of
$1
where is supposed that the commit message would be assigned, but if we look at the console output, it is empty.git commit -m "feat: adding commit validation" Husky is awesome! π .husky/pre-commit
[Husky] π Loading tasks ...
[Husky] β‘ Preparing task 'commit-message-linter' [Husky] β Executing task 'commit-message-linter' ... Hi
script execution failed
β Task 'commit-message-linter' failed in 722ms
husky - pre-commit hook exited with code 1 (error)
OS: Windows 10. Shell: PowerShell: 5.1
Steps to reproduce
dotnet new tool-manifest
dotnet tool install Husky
dotnet husky install
dotnet husky add pre-commit -c "echo 'Welcome to pre-commit git hook with Husky.Net'"
git add .husky/pre-commit
.husky
folder withpass hook arguments to task
husky run --args "$1" "$2"
echo 'Husky is awesome! π' echo $0
echo "$(cat $1)"
dotnet husky run --name "commit-message-linter" --args "$1" echo echo Great work! π₯
echo 'Building code π¨' dotnet build
echo 'Running tests π§ͺ' dotnet test
git commit -m "feat: adding commit validation"