Skip to content

Commit

Permalink
Merge pull request #3 from Calinou/fix-shellcheck-warnings
Browse files Browse the repository at this point in the history
Fix warnings reported by ShellCheck and use Bash strict mode
  • Loading branch information
akien-mga committed Feb 10, 2019
2 parents 2d08614 + 2e37a50 commit 4bc5b5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
13 changes: 8 additions & 5 deletions list-authors.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

if [ -z $1 ]; then
set -euo pipefail
IFS=$'\n\t'

if [ -z "$1" ]; then
echo "Pass a commit hash as argument to list authors between that commit and HEAD."
exit 1
fi
Expand All @@ -10,16 +13,16 @@ commit=$1
rm -f authors.txt langs.txt

for file in weblate/*.po; do
authors=$(git log $commit..HEAD --date=format:"%Y" --format="%aN <%aE>, %ad." $file | grep -v 'anonymous' | sort -u)
if [ ! -z "$authors" ]; then
authors=$(git log "$commit"..HEAD --date=format:"%Y" --format="%aN <%aE>, %ad." "$file" | grep -v 'anonymous' | sort -u)
if [ -n "$authors" ]; then
new_authors=""
while read -r author; do
found=$(grep "$author" $file)
found=$(grep "$author" "$file")
if [ -z "$found" ]; then
new_authors+=$author$'\n'
fi
done <<< "$authors"
if [ ! -z "$new_authors" ]; then
if [ -z "$new_authors" ]; then
echo "$file" >> langs.txt
echo -e "\n* $file:\n" >> authors.txt
echo "$new_authors" >> authors.txt
Expand Down
15 changes: 9 additions & 6 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

set -euo pipefail
IFS=$'\n\t'

# Defines
SOURCE_DIR="docs"
SPHINX_TEMPLATES_DIR="sphinx/templates"
Expand Down Expand Up @@ -100,7 +103,7 @@ if [ "$update_weblate_pot" = true ]; then
if [ ! -d "$WEBLATE_DIR" ]; then
mkdir $WEBLATE_DIR
fi
msgcat -o $WEBLATE_TEMPLATE $SPHINX_TEMPLATES
msgcat -o $WEBLATE_TEMPLATE "$SPHINX_TEMPLATES"
sed -i 's@Report-Msgid-Bugs-To: [^"]*@Report-Msgid-Bugs-To: https://github.com/godotengine/godot-docs-l10n\\n@' $WEBLATE_TEMPLATE
fi

Expand All @@ -109,8 +112,8 @@ if [ "$update_weblate_po" = true ]; then
echo "=== Merging Weblate PO files with Weblate template ==="
for po in $WEBLATE_POFILES; do
echo "Merging $po..."
msgmerge -w 79 $po $WEBLATE_TEMPLATE > "$po".new
mv -f "$po".new $po
msgmerge -w 79 "$po" $WEBLATE_TEMPLATE > "$po".new
mv -f "$po".new "$po"
done
fi

Expand All @@ -131,16 +134,16 @@ if [ "$update_sphinx_po" = true ]; then
rm -rf $SPHINX_PO_DIR
mkdir $SPHINX_PO_DIR
for lang in $SPHINX_BUILD_LANGS; do
po=$WEBLATE_DIR"/"$lang".po"
po=$WEBLATE_DIR"/$lang.po"
echo "Merging $po..."
langdir="$SPHINX_PO_DIR/$lang/LC_MESSAGES"
mkdir -p "$langdir"
for template in $SPHINX_TEMPLATES; do
page=$(basename "$template" .pot)
dirpath=$(dirname "$template" | sed -e 's@'$SPHINX_TEMPLATES_DIR'@'$langdir'@')
dirpath=$(dirname "$template" | sed -e 's@'$SPHINX_TEMPLATES_DIR'@'"$langdir"'@')
mkdir -p "$dirpath"
output="$dirpath/$page.po"
msgmerge --lang=$lang -C "$po" "$template" "$template" -o "$output"
msgmerge --lang="$lang" -C "$po" "$template" "$template" -o "$output"
done
done
fi

0 comments on commit 4bc5b5b

Please sign in to comment.