#!/usr/bin/env sh12set -uo pipefail3shopt -s globstar45echo -e ".gitignore validation..."67# Get a list of files that exist in the repo but are ignored.89# The --verbose flag also includes files un-ignored via ! prefixes.10# We filter those out with a somewhat awkward `awk` directive.11# (Explanation: Split each line by : delimiters,12# see if the actual gitignore line shown in the third field starts with !,13# if it doesn't, print it.)1415# ignorecase for the sake of Windows users.1617output=$(git -c core.ignorecase=true check-ignore --verbose --no-index **/* | \18awk -F ':' '{ if ($3 !~ /^!/) print $0 }')1920# Then we take this result and return success if it's empty.21if [ -z "$output" ]; then22exit 023else24# And print the result if it isn't.25echo "$output"26exit 127fi282930