Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display GIT pre-commit hook output in visual studio 2019

I'm using the following git pre-commit hook to run unit-test on a project prior to commit

echo "Starting test runner..."
exec dotnet test "MyProject.UnitTest.csproj"

if [ $? -ne 0 ]; then
echo >&2 "Tests must pass before commit!"
exit 1
fi

The hook is taken into account in Visual Studio when I commit, but I get a common error: "One or more errors occurred". The hook seems to be working correctly as I do not have any issue if all my unit-test pass.

Do you know a way of showing the output of the hook in visual studio, to get a proper error details ?

like image 219
JulienRousselle Avatar asked Jul 11 '26 22:07

JulienRousselle


1 Answers

For that, I'm afraid you'll have to use the command prompt when committing your changes. You could use the "Package Manager Console" to run your git commands if you do not want to leave Visual Studio. Then you can see the output in the "Source-Control - Git" output window.

enter image description here

like image 133
Ε Г И І И О Avatar answered Jul 13 '26 17:07

Ε Г И І И О



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!