From 90f3992036b2f2fc1b4d08d1cc854d9cd62f6930 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 1 Jul 2023 08:40:58 -0500 Subject: [PATCH 1/2] Fix: incorrectly .gitignored files. --- platform/android/java/editor/src/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 platform/android/java/editor/src/.gitignore diff --git a/platform/android/java/editor/src/.gitignore b/platform/android/java/editor/src/.gitignore new file mode 100644 index 000000000000..c081ec3425d0 --- /dev/null +++ b/platform/android/java/editor/src/.gitignore @@ -0,0 +1 @@ +!/debug From 7ea171adca8d28d10aae68cfe8f36094683bc491 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 1 Jul 2023 08:32:30 -0500 Subject: [PATCH 2/2] Add static check for overzealous .gitignores. --- .github/workflows/static_checks.yml | 5 +++++ misc/scripts/gitignore_check.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 misc/scripts/gitignore_check.sh diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 6133780688a9..af308e885a6c 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -41,6 +41,11 @@ jobs: files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ') echo "CHANGED_FILES=$files" >> $GITHUB_ENV + # This needs to happen before Python and npm execution; it must happen before any extra files are written. + - name: .gitignore checks (gitignore_check.sh) + run: | + bash ./misc/scripts/gitignore_check.sh + - name: File formatting checks (file_format.sh) run: | bash ./misc/scripts/file_format.sh changed.txt diff --git a/misc/scripts/gitignore_check.sh b/misc/scripts/gitignore_check.sh new file mode 100644 index 000000000000..f162e25391b0 --- /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