-
Notifications
You must be signed in to change notification settings - Fork 710
/
l10n-fetch-lint-compile.sh
executable file
·50 lines (40 loc) · 1.2 KB
/
l10n-fetch-lint-compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Run this from the project root--not from this directory!
git clone https://github.com/mozilla-l10n/sumo-l10n.git locale
cd locale
postatus_file=../kitsune/sumo/static/postatus.txt
head_hash=$(git log -n1 --format=%H)
echo "po status for commit ${head_hash}:" > $postatus_file
echo -e "(if nothing appears below, no errors were detected)\\n" >> $postatus_file
function lintpo() {
commit=$1
pofile=$2
log=$(../scripts/dennis_shim.py lint --errorsonly "${pofile}")
if [ $? -eq 0 ]
then
compilemo $pofile
return 0
fi
if [ $commit = "HEAD" ]
then
echo "$log" >> $postatus_file
echo -e "\\n" >> $postatus_file
fi
# find the next most recent commit the file was modified in
commit=$(git log -n1 --format=%H ${commit}~1 -- $pofile)
echo "lint returned an error, trying $commit"
# checkout the file from that commit
git checkout $commit $pofile
# try linting again
lintpo $commit $pofile
}
function compilemo() {
dir=`dirname $1`
stem=`basename $1 .po`
msgfmt -o "${dir}/${stem}.mo" "$1"
}
for pofile in `find ./ -name "*.po"`
do
echo "Linting and compiling ${pofile}..."
lintpo HEAD $pofile
done