Merge "Test translation imports"
This commit is contained in:
commit
221de77380
@ -22,6 +22,9 @@ TOPIC=zanata/translations
|
|||||||
# Used for setup.py babel commands
|
# Used for setup.py babel commands
|
||||||
QUIET="--quiet"
|
QUIET="--quiet"
|
||||||
|
|
||||||
|
# Have invalid files been found?
|
||||||
|
INVALID_PO_FILE=0
|
||||||
|
|
||||||
# Get a module name of a project
|
# Get a module name of a project
|
||||||
function get_modulename {
|
function get_modulename {
|
||||||
local project=$1
|
local project=$1
|
||||||
@ -389,8 +392,12 @@ function setup_django_openstack_auth {
|
|||||||
'{locale_with_underscore}/LC_MESSAGES/django.po' -f zanata.xml
|
'{locale_with_underscore}/LC_MESSAGES/django.po' -f zanata.xml
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter out files that we do not want to commit
|
# Filter out files that we do not want to commit.
|
||||||
|
# Sets global variable INVALID_PO_FILE to 1 if any invalid files are
|
||||||
|
# found.
|
||||||
function filter_commits {
|
function filter_commits {
|
||||||
|
local ret
|
||||||
|
|
||||||
# Don't add new empty files.
|
# Don't add new empty files.
|
||||||
for f in $(git diff --cached --name-only --diff-filter=A); do
|
for f in $(git diff --cached --name-only --diff-filter=A); do
|
||||||
# Files should have at least one non-empty msgid string.
|
# Files should have at least one non-empty msgid string.
|
||||||
@ -417,6 +424,21 @@ function filter_commits {
|
|||||||
| egrep -v "$REGEX" \
|
| egrep -v "$REGEX" \
|
||||||
| egrep -c "^([+][^+#])")
|
| egrep -c "^([+][^+#])")
|
||||||
set -e
|
set -e
|
||||||
|
# Check that imported po files are valid
|
||||||
|
if [[ $f =~ .po$ ]] ; then
|
||||||
|
set +e
|
||||||
|
msgfmt --check-format -o /dev/null $f
|
||||||
|
ret=$?
|
||||||
|
set -e
|
||||||
|
if [ $ret -ne "0" ] ; then
|
||||||
|
# Set change to zero so that next expression reverts
|
||||||
|
# change of this file.
|
||||||
|
changed=0
|
||||||
|
echo "ERROR: File $f is an invalid po file."
|
||||||
|
echo "ERROR: The file has not been imported and needs fixing!"
|
||||||
|
INVALID_PO_FILE=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
if [ $changed -eq 0 ]; then
|
if [ $changed -eq 0 ]; then
|
||||||
git reset -q "$f"
|
git reset -q "$f"
|
||||||
git checkout -- "$f"
|
git checkout -- "$f"
|
||||||
|
@ -213,3 +213,9 @@ filter_commits
|
|||||||
|
|
||||||
# Propose patch to gerrit if there are changes.
|
# Propose patch to gerrit if there are changes.
|
||||||
send_patch "$BRANCH"
|
send_patch "$BRANCH"
|
||||||
|
|
||||||
|
if [ $INVALID_PO_FILE -eq 1 ] ; then
|
||||||
|
echo "At least one po file in invalid. Fix all invalid files on the"
|
||||||
|
echo "translation server."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user