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] make weblate.push.translations #379

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

dalf
Copy link
Member

@dalf dalf commented Oct 3, 2021

What does this PR do?

Even when there are changes, the function exit without pushing them.

Not tested, see log:
https://github.com/searxng/searxng/runs/3783399235?check_suite_focus=true#step:6:235

Extract:

extracting messages from searx/templates/simple/result_templates/images.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
extracting messages from searx/templates/simple/result_templates/key-value.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
extracting messages from searx/templates/simple/result_templates/map.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
extracting messages from searx/templates/simple/result_templates/torrent.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
extracting messages from searx/templates/simple/result_templates/videos.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
writing PO template file to /home/runner/work/searxng/searxng/cache/translations/searx/translations/messages.pot

The log stops without anymore.

Which lead me to think this condition is always true:

searxng/manage

Lines 269 to 271 in 47eb836

if [ "$exitcode" ]; then
return $exitcode
fi

This PR change line 269 to

if [ "$exitcode" -gt 0 ]; the

Local dumb tests:

[ "0" ] && echo "a"
[ "0" -gt 0 ] && echo "b"

Why is this change important?

Bug fix

How to test this PR locally?

Author's checklist

Related issues

Even when there are changes, the function exit without pushing them.
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.

Seems to fix the issue / lets merge and see if it works in practice ..

Sorry, this was my fail, I fixed #293 (comment)

@return42 return42 merged commit cebc0e3 into master Oct 4, 2021
@return42 return42 deleted the fix-weblate-push-translations branch October 4, 2021 07:33
@dalf
Copy link
Member Author

dalf commented Oct 4, 2021

It works: 7d9ffd6

@return42
Copy link
Member

return42 commented Oct 4, 2021

Remote weblate (https://weblate.bubu1.eu/git/searxng/searxng/)

before::

f3210ded5 master           [translations] Translated using Weblate (French)
3834942d1 translations     [translations] Translated using Weblate (Arabic)

after:

f3210ded5 master           [translations] Translated using Weblate (French)
7d9ffd680 translations     [translations] update messages.pot and messages.po files\nFrom cebc0e39 - 2021-10-04 - Markus Heiser <markus.heiser@darmarIT.de>

May be we can fix the \n issue ..

searxng/manage

Line 304 in cebc0e3

last_commit_message="[translations] update messages.pot and messages.po files\nFrom ${last_commit_detail}"

An alternative might be:

diff --git a/manage b/manage
index e3bf27b50..deefd482c 100755
--- a/manage
+++ b/manage
@@ -240,7 +240,7 @@ weblate.push.translations() {
     # 5. Notify Weblate to pull updated 'master' & 'translations' branch.
 
     local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
-          last_commit_message exitcode
+          exitcode
     messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
     (   set -e
         pyenv.activate
@@ -301,11 +301,12 @@ weblate.push.translations() {
         # git add/commit/push
         last_commit_hash=$(git log -n1  --pretty=format:'%h')
         last_commit_detail=$(git log -n1 --pretty=format:'%h - %as - %aN <%ae>' "${last_commit_hash}")
-        last_commit_message="[translations] update messages.pot and messages.po files\nFrom ${last_commit_detail}"
 
         pushd "${TRANSLATIONS_WORKTREE}"
         git add searx/translations
-        git commit -m "${last_commit_message}"
+        git commit \
+            -m "[translations] update messages.pot and messages.po files" \
+            -m "From ${last_commit_detail}"
         git push
         popd

return42 added a commit to return42/searxng that referenced this pull request Oct 4, 2021
Fix `\n` issue in the commit message [1] by using multiple `-m` options [2]::

    7d9ffd6 translations     [translations] update messages.pot and messages.po files\nFrom cebc0e3 - 2021-10-04 - Markus Heiser <markus.heiser@darmarIT.de>

[1] searxng#379 (comment)
[2] https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--mltmsggt

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
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.

None yet

2 participants