diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-29 12:41:53 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-29 12:41:53 +0200 |
commit | 5b5471e30a8885b309625529a10941613fefc48f (patch) | |
tree | 63806ccdab1045d3274b877e696391a98cb4fdc9 /misc | |
parent | 76d318dbd13bd09a9690c0b459cb30f9ab6903f0 (diff) | |
parent | 7ea171adca8d28d10aae68cfe8f36094683bc491 (diff) | |
download | redot-engine-5b5471e30a8885b309625529a10941613fefc48f.tar.gz |
Merge pull request #78908 from zorbathut/pr_gitignore
Add static check for overzealous .gitignores and fix an example of such.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/scripts/gitignore_check.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/misc/scripts/gitignore_check.sh b/misc/scripts/gitignore_check.sh new file mode 100644 index 0000000000..f162e25391 --- /dev/null +++ b/misc/scripts/gitignore_check.sh @@ -0,0 +1,26 @@ +set -uo pipefail +shopt -s globstar + +echo -e ".gitignore validation..." + +# Get a list of files that exist in the repo but are ignored. + +# The --verbose flag also includes files un-ignored via ! prefixes. +# We filter those out with a somewhat awkward `awk` directive. + # (Explanation: Split each line by : delimiters, + # see if the actual gitignore line shown in the third field starts with !, + # if it doesn't, print it.) + +# ignorecase for the sake of Windows users. + +output=$(git -c core.ignorecase=true check-ignore --verbose --no-index **/* | \ + awk -F ':' '{ if ($3 !~ /^!/) print $0 }') + +# Then we take this result and return success if it's empty. +if [ -z "$output" ]; then + exit 0 +else + # And print the result if it isn't. + echo "$output" + exit 1 +fi |