Browse Source

Add special "hook" mode to polint to fix language detection.

The language is detected from the filename which doesn't work when
called from the hook where a temporary file is processed.
pull/338/head
Joachim Bauch 9 years ago
parent
commit
bc25d998d7
  1. 2
      src/hooks/pre-commit.hook
  2. 19
      src/i18n/helpers/polint.py

2
src/hooks/pre-commit.hook

@ -78,7 +78,7 @@ fi @@ -78,7 +78,7 @@ fi
for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.po$"` ; do
echo "Checking ${file}"
nf=`git checkout-index --temp ${file} | cut -f 1`
./src/i18n/helpers/polint.py "${nf}"
./src/i18n/helpers/polint.py --hook "${nf}" "${file}"
r=$?
rm "${nf}"
if [ $r != 0 ] ; then

19
src/i18n/helpers/polint.py

@ -187,13 +187,28 @@ def main(): @@ -187,13 +187,28 @@ def main():
_, POT_DATA, _ = parsepo(os.path.join(ROOT, 'messages.pot'))
errors = 0
filenames = sys.argv[1:]
try:
sys.argv.remove('--hook')
except ValueError:
is_hook = False
else:
is_hook = True
if is_hook:
filename, orig_filename = sys.argv[1:]
filenames = [filename]
else:
orig_filename = None
filenames = sys.argv[1:]
show_filenames = False
if not filenames:
filenames = glob.glob(os.path.join(ROOT, 'messages-*.po'))
show_filenames = True
for filename in filenames:
language = os.path.basename(filename)[9:-3]
if orig_filename:
language = os.path.basename(orig_filename)[9:-3]
else:
language = os.path.basename(filename)[9:-3]
if show_filenames:
print 'Checking %s (%s)' % (filename, language)
try:

Loading…
Cancel
Save