Mise en place d'un lock git - étape 1 - #4328
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new early-return lock behavior can trigger an infinite job requeue loop (and queue growth) when desynchronized files remain while synchronization is locked.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces the first backend slice of a “Git synchronization lock” for communication websites, allowing synchronization to be disabled (and attributed to a user) so that no Git pushes occur while the lock is active.
Changes:
- Adds
synchronization_locked_by_idtocommunication_websites(nullable FK tousers, nullified on user deletion). - Implements lock state + lock/unlock helpers on websites, and propagates lock checks into
Git::Repositoryand Git providers to prevent pushes/remote updates. - Adds service-level tests ensuring no pushes occur while locked and that git files remain desynchronized.
File summaries
| File | Description |
|---|---|
| test/services/git_repository_test.rb | Adds tests covering “no push when locked” (GitHub/GitLab) and “git files remain desynchronized when locked”. |
| db/schema.rb | Updates schema version and reflects the new synchronization_locked_by_id column, index, and FK. |
| db/migrate/20260903090000_add_synchronization_locked_by_to_communication_websites.rb | Adds the synchronization_locked_by reference (UUID) with FK to users and on_delete: :nullify. |
| app/services/git/repository.rb | Introduces synchronization_locked? and prevents sync/theme/init/secrets operations when locked. |
| app/services/git/providers/gitlab.rb | Prevents update_theme! and push from executing when locked. |
| app/services/git/providers/github.rb | Prevents update_theme! and push from executing when locked. |
| app/services/git/providers/abstract.rb | Adds a provider-level synchronization_locked? helper delegating to the repository. |
| app/models/communication/website/with_git_repository.rb | Adds synchronization_locked_by association and lock/unlock helpers + synchronization_locked? predicate. |
| app/models/communication/website.rb | Updates the schema annotations to include the new column/index/FK. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
SebouChu
reviewed
Sep 4, 2026
SebouChu
reviewed
Sep 4, 2026
SebouChu
reviewed
Sep 4, 2026
arnaudlevy
reviewed
Sep 4, 2026
SebouChu
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type
Description
Première partie de la mise en place d'un lock Git.
Pas d'interface graphique pour le moment, ce sera pour le lot 2.
Mon idée est que selon la personne qui a déclenché le lock on puisse gérer derrière. Par exemple si un admin a lock, seul un admin ou un server admin peut unlock. Si un website manager a lock, un droit > peut unlock. Ce qui fera que si c'est un server_admin qui a lock (= mode maintenance) personne ne pourra unlock sauf un server_admin.
Dans le lot 2 il faudra les interfaces pour activer ce lock. Il en faut une au niveau du website, activable par un admin/website_manager. Probablement au même niveau que le bouton qui force la synchronisation immédiate (il faudra bien sûr aussi les actions de controller qui vont avec, et les abilities). Il faudra aussi une interface en /server qui permette de déclencher le lock sur TOUS les websites.
Une fois le lock activé un bandeau doit être présent sur toutes les pages d'admin du site web.
Il faudra coupler ça avec le système "d'alerte" présent sur toutes les pages du BO dont on a parlé en assemblée ce matin.
Cette alerte doit avoir un bouton "réactiver la synchronisation" à condition que le user qui a lock n'ait pas un rôle au dessus.
Le fait d'avoir l'id de l'utilisateur qui a lock permettra aussi de conditionner l'affichage. Par exemple si c'est lock par un admin "John Doe a bloqué la synchronisation avec Git". Si c'est un server_admin (dont les noms ne sont pas forcément parlants pour les utilisateurs) on peut avoir un message plus neutre "Une maintenance est en cours".
On a donc dès à présent avec cette PR un système qui interrompt tous les envois physiques sur Git, mais qui ne bloque pas les analyses de fichiers, les git_file marqués comme désynchronisés, etc.
Ca peut être appelé avec cette commande :
`Communication::Website.find(website_id).lock_synchronization!(User.find(user_id))
Niveau d'incidence
Changement d'interface