From a678b6a613bec16f902746e22f5e6c13897be6ff Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 20 Sep 2014 09:06:48 +0200 Subject: [PATCH] Improve filtering of translations Add new test: Do not add new empty files without any translations or messages. Those are not needed. Enhance test: When filtering translations and checking for only changes to .pot files, check first that a file was really changed. Otherwise, the .po files might have just timestamp changes and get filtered out and we end with a patch with only the pot file in it. Change-Id: I667b76baa5d779488098e1a297f38ea66e53fb6d --- .../slave_scripts/common_translation_update.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/openstack_project/files/slave_scripts/common_translation_update.sh b/modules/openstack_project/files/slave_scripts/common_translation_update.sh index 6aecbd20ea..75ace6d70f 100644 --- a/modules/openstack_project/files/slave_scripts/common_translation_update.sh +++ b/modules/openstack_project/files/slave_scripts/common_translation_update.sh @@ -286,16 +286,23 @@ function setup_django_openstack_auth () # Filter out files that we do not want to commit function filter_commits () { + # Don't add new empty files. + for f in `git diff --cached --name-only --diff-filter=A` + do + # Files should have at least one non-empty msgid string. + if grep -q 'msgid "[^"]' "$f" ; then + git reset -q "$f" + rm "$f" + fi + done + # Don't send files where the only things which have changed are # the creation date, the version number, the revision date, # comment lines, or diff file information. + # Also, don't send files if only .pot files would be changed. PO_CHANGE=0 for f in `git diff --cached --name-only` do - # Check for all files endig with ".po" - if [[ $f =~ .po$ ]] ; then - PO_CHANGE=1 - fi # It's ok if the grep fails set +e changed=$(git diff --cached "$f" \ @@ -306,6 +313,9 @@ function filter_commits () then git reset -q "$f" git checkout -- "$f" + # Check for all files endig with ".po" + elif [[ $f =~ .po$ ]] ; then + PO_CHANGE=1 fi done # If no po file was changed, only pot source files were changed