Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

dalf
Copy link
Member

@dalf dalf commented Sep 6, 2021

What does this PR do?

After each commit on the master branch, there is a call to weblate.push.translations:

if: ${{ github.repository_owner == 'searxng' && github.ref == 'refs/heads/master' }}

make V=1 weblate.push.translations

weblate.push.translations locks weblate each time.

This PR locks weblate only when there is an actual change of messages.pot.

Why is this change important?

See #290 : keep weblate history clean, avoid triggers on lock.

How to test this PR locally?

N/A

Author's checklist

Related issues

Close #290

manage Outdated
@@ -261,6 +259,12 @@ weblate.push.translations() {
return 0
Copy link
Member

@return42 return42 Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not wrong, this return ends the subshell started in line 242 by ( . The shell will continue where the subshell ends, see closing ) below .. and pyenv.cmd wlc unlock will be executed .. or I'm wrong?

update: compare with #290 (comment) where I moved the block with the return out of the subprocess.

Copy link
Member Author

@dalf dalf Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to keep set -e for the block before pyenv.cmd wlc lock ?

Copy link
Member

@return42 return42 Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this patch ... update see #379

diff --git a/manage b/manage
index 6f6f1a4f..488a93cc 100755
--- a/manage
+++ b/manage
@@ -240,9 +240,6 @@ weblate.push.translations() {
     local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
           last_commit_message exitcode
     (   set -e
-        # lock change on weblate
-        pyenv.cmd wlc lock
-
         # get translations branch in git worktree (TRANSLATIONS_WORKTREE)
         weblate.translations.worktree
 
@@ -258,8 +255,18 @@ weblate.push.translations() {
                             git diff -- "searx/translations/messages.pot")
         if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
             build_msg BABEL 'no changes detected, exiting'
-            return 0
+            return 1
         fi
+        return 0
+    )
+    exitcode=$?
+    if [ "$exitcode" ]; then # FIX see #379 :: if [ "$exitcode" -gt 0 ]; then
+       return 0
+    fi
+
+    (   set -e
+        # lock change on weblate
+        pyenv.cmd wlc lock
 
         # save messages.pot in the translations branch for later
         pushd "${TRANSLATIONS_WORKTREE}"

@return42
Copy link
Member

return42 commented Sep 6, 2021

Copy link
Member

@return42 return42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments.

@dalf
Copy link
Member Author

dalf commented Sep 6, 2021

Does https://github.com/searxng/searxng/blob/master/docs/dev/translation.svg needs an update?

The check is not shown, and it is not accurate.
It should be better with this:

image

The creation of the worktree / git pull are not shown (it is already the case).

@return42
Copy link
Member

return42 commented Sep 6, 2021

It should be better with this:

Do you like to update the svg in the repository along with this PR?

Copy link
Member

@return42 return42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant test it, but LGTM / Thanks!

@dalf dalf merged commit b57d776 into searxng:master Sep 6, 2021
@dalf dalf deleted the fix-290 branch October 2, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

github job "Update translations branch " locks and unlock weblate, even if there are no changes detected
2 participants