summaryrefslogtreecommitdiffstats
path: root/misc/scripts/dotnet_format.sh
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2024-02-27 21:09:04 +0100
committerRaul Santos <raulsntos@gmail.com>2024-03-02 08:25:48 +0100
commit97851f03401537b7fa0affc50a5800eda351c4b8 (patch)
tree65c983be347a5423cfeeb492ef9d3722ee0f019d /misc/scripts/dotnet_format.sh
parentf5dbbf7fd067bbb435989a6839fe37e03e4ba057 (diff)
downloadredot-engine-97851f03401537b7fa0affc50a5800eda351c4b8.tar.gz
Move dotnet-format script to pre-commit
Co-authored-by: Paul Joannon <437025+paulloz@users.noreply.github.com>
Diffstat (limited to 'misc/scripts/dotnet_format.sh')
-rwxr-xr-xmisc/scripts/dotnet_format.sh37
1 files changed, 0 insertions, 37 deletions
diff --git a/misc/scripts/dotnet_format.sh b/misc/scripts/dotnet_format.sh
deleted file mode 100755
index e2b4ba5e43..0000000000
--- a/misc/scripts/dotnet_format.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env bash
-
-# This script runs dotnet format on all relevant files in the repo.
-# This is the primary script responsible for fixing style violations in C# files.
-
-set -uo pipefail
-
-# Create dummy generated files.
-echo "<Project />" > modules/mono/SdkPackageVersions.props
-mkdir -p modules/mono/glue/GodotSharp/GodotSharp/Generated
-echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharp/Generated/GeneratedIncludes.props
-mkdir -p modules/mono/glue/GodotSharp/GodotSharpEditor/Generated
-echo "<Project />" > modules/mono/glue/GodotSharp/GodotSharpEditor/Generated/GeneratedIncludes.props
-
-# Loops through all C# projects tracked by Git.
-git ls-files -- '*.csproj' \
- ':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
-while read -r f; do
- # Run dotnet format.
- dotnet format "$f"
-done
-
-diff=$(git diff --color)
-
-# If no diff has been generated all is OK, clean up, and exit.
-if [ -z "$diff" ] ; then
- printf "\e[1;32m*** Files in this commit comply with the dotnet format style rules.\e[0m\n"
- exit 0
-fi
-
-# A diff has been created, notify the user, clean up, and exit.
-printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
-# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
-printf "%s\n" "$diff" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
-
-printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
-exit 1