[fix] translation: lock weblate only when there is an actual change of messages.pot

Close #290
This commit is contained in:
Alexandre Flament 2021-09-06 12:09:20 +02:00
parent 33ea1d5909
commit 2a5f690a71
2 changed files with 29 additions and 12 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

21
manage
View file

@ -239,16 +239,14 @@ weblate.push.translations() {
local messages_pot diff_messages_pot last_commit_hash last_commit_detail \ local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
last_commit_message exitcode last_commit_message exitcode
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
( set -e ( set -e
# lock change on weblate
pyenv.cmd wlc lock
# get translations branch in git worktree (TRANSLATIONS_WORKTREE) # get translations branch in git worktree (TRANSLATIONS_WORKTREE)
weblate.translations.worktree weblate.translations.worktree
# update messages.pot in the master branch # update messages.pot in the master branch
build_msg BABEL 'extract messages from source files and generate POT file' build_msg BABEL 'extract messages from source files and generate POT file'
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
pyenv.cmd pybabel extract -F babel.cfg \ pyenv.cmd pybabel extract -F babel.cfg \
-o "${messages_pot}" \ -o "${messages_pot}" \
"searx/" "searx/"
@ -258,8 +256,25 @@ weblate.push.translations() {
git diff -- "searx/translations/messages.pot") git diff -- "searx/translations/messages.pot")
if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
build_msg BABEL 'no changes detected, exiting' build_msg BABEL 'no changes detected, exiting'
return 42
fi
return 0
)
exitcode=$?
if [ "$exitcode" -eq 42 ]; then
return 0 return 0
fi fi
if [ "$exitcode" ]; then
return $exitcode
fi
(
set -e
# lock change on weblate
# weblate may add commit(s) since the call to "weblate.translations.worktree".
# this is not a problem because after this line, "weblate.to.translations"
# calls again "weblate.translations.worktree" which calls "git pull"
pyenv.cmd wlc lock
# save messages.pot in the translations branch for later # save messages.pot in the translations branch for later
pushd "${TRANSLATIONS_WORKTREE}" pushd "${TRANSLATIONS_WORKTREE}"