Weblate and Git VCS: Synchronization Loop Prevention during Automated Commits
0 reputation · 20 Jun 2023, 14:44 UTC
0 reputation · 20 Jun 2023, 14:44 UTC
Weblate manages translation data by mirroring a database state with a remote Git repository. This integration relies on asynchronous Celery tasks to handle pushes and pulls, ensuring that UI responsiveness is maintained during large commit operations.
A critical design constraint involves the interaction between Weblate's automatic commit triggers and external Git hooks. If a remote repository is configured with hooks that trigger an immediate push back to the source upon receiving a commit, there is a risk of creating an infinite synchronization loop.
Given the current push/pull model, it is unclear how the system distinguishes between a legitimate external contribution and a mirrored commit generated by Weblate's own automation.
29275 reputation · 20 Jun 2023, 22:52 UTC
Weblate distinguishes its automated commits from external contributions by examining the commit author (email/name) or by looking for a configurable marker in the commit message (e.g., [skip ci] or [skip weblate]). When a pull operation retrieves commits, Weblate skips any that match the designated author or contain the marker, treating them as already‑mirrored changes.
weblate-bot@example.com) for Weblate’s Git operations.pre‑receive or post‑receive hook.pre‑receive hook on the remote Git repository that exits silently when:
[skip weblate]).If your CI/CD pipelines already use a specific skip marker or run under a distinct service account, please confirm that detail; it determines whether you need to add the marker to Weblate’s commits or adjust the hook’s author filter.
Use comments to ask for clarification. Post a solution as an answer.
2,060 reputation · 21 Jun 2023, 01:54 UTC
Weblate appends a marker to every automated commit. The default is [weblate], but the string can be changed in the component’s VCS settings under Commit message template. When you modify the marker you must also update any pre‑receive hooks that rely on the old pattern.
All Weblate pushes use a dedicated author email (e.g. [contact removed]). This is set in the same VCS configuration. If your CI system rewrites the author, the hook will not detect the push as a Weblate commit unless the marker is present.
pre‑receive script that exits with a non‑zero status when git rev-list --grep="\[weblate\]" HEAD returns any commits.#!/bin/sh
if git rev-list --grep='\[weblate\]' HEAD | grep -q .; then
echo 'Rejecting Weblate auto‑commit'; exit 1
fi
exit 0
Most CI platforms support a skip marker. In GitHub Actions, you can add:
if: contains(github.event.head_commit.message, '[weblate]')
run: echo 'Skipping job – Weblate commit'
This ensures that a pipeline triggered by a Weblate push does not start a new cycle.