I was setting up git-hooks in my .Net project and I came across this problem with Husky.NET pre-push hooks. They don’t show errors related to the commands executed. The weird part is, pre-commit hook clearly displays this error.
Check out the pre-commit file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "Husky.NET Started"
echo "Running Pre-Commit Hook"
dotnet build
dotnet tool run dotnet-csharpier ./Ecommerce.Application/ ./Ecommerce.Domain/ ./Ecommerce.Infrastructure/ ./Ecommerce.Presentation/Api/ ./Ecommerce.Presentation/Contracts/ ./Ecommerce.Tests/
echo "Husky.NET Finished"
When I try to commit it will show this error message (which is exactly what I want)
git -c user.useConfigOnly=true commit –quiet
Husky.NET Started
Running Pre-Commit Hook
Determining projects to restore…
All projects are up-to-date for restore.
Contracts -> C:UsersdagteDocumentsvscodeEcommerce_Platform.NETbinDebugnet8.0Contracts.dll
Ecommerce.Domain -> C:UsersdagteDocumentsvscodeEcommerce_Platform.NETbinDebugnet8.0Ecommerce.Domain.dll
But sadly the pre-push hook as shown below:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "Husky.NET Started"
echo "Running Pre-Push Hook"
dotnet build || { echo "Build failed!"; exit 1; }
echo "Husky.NET Finished"
only displays the following:
git push origin main:main
error: failed to push some refs to ‘https://github.com/dagweg/Ecommerce_Platform.NET.git’
Does anyone know a way to display more information like the pre-commit hooks (shown above).
Thanks for your help.
Additional info:
- The husky.NET version is 0.7.2