Check for empty JSON translation files
JSON translation files do not contain the "msgid" string and are
currently being removed during commit filtering. This runs a different
check for JSON files, ensuring it contains string keys.
@@ -431,11 +431,21 @@ function filter_commits {
# Don't add new empty files.
for f in $(git diff --cached --name-only --diff-filter=A); do
+ if [[ $f =~ .po$ ]] ; then
# Files should have at least one non-empty msgid string.
if ! grep -q 'msgid "[^"]' "$f" ; then
git reset -q "$f"
rm "$f"
fi
+ fi
+ if [[ $f =~ .json$ ]] ; then
+ # Ignore the locale key and confirm there are string keys
+ # in the messages dictionary itself.
+ if ! grep -q '"[^"].*":\s*"' "$f" ; then
+ git reset -q "$f"
+ rm "$f"
+ fi
+ fi
done
# Don't send files where the only things which have changed are
