From 7604c7b08888487c797002ad8c141793cb3f91c1 Mon Sep 17 00:00:00 2001 From: Andoni Morales Alastruey Date: Wed, 23 Mar 2022 21:46:23 +0100 Subject: [PATCH] csharp: check format in the pre-commit hook Part-of: --- scripts/git-hooks/pre-commit.hook | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/git-hooks/pre-commit.hook b/scripts/git-hooks/pre-commit.hook index 3c1062b9e0..1224ffd3d9 100755 --- a/scripts/git-hooks/pre-commit.hook +++ b/scripts/git-hooks/pre-commit.hook @@ -80,4 +80,28 @@ echo "========================================================================== exit 1 fi done + +csharp_files=` git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "^subprojects/gstreamer-sharp/.*cs$" ` +if test "x$csharp_files" != "x"; then + version=`dotnet-format --version 2>/dev/null` + if test "x$version" = "x"; then + echo "GStreamer git pre-commit hook:" + echo "Did not find dotnet-format required to format C# files, please install it before continuing." + exit 1 + fi + scripts/format-csharp --check + r=$? + if [ $r != 0 ] ; then +echo "=================================================================================================" +echo " Code style error: " +echo " " +echo " Please fix before committing, running from the top-level directory: " +echo " scripts/format-chsarp " +echo " " +echo " Don't forget to run git add before trying to commit again. " +echo "=================================================================================================" + exit 1 + fi +fi + echo "--Checking style pass--"