Skip to content

Mise en place d'un lock git - étape 1 - #4328

Merged
SebouChu merged 8 commits into
mainfrom
lock_send_to_git_step_1
Sep 7, 2026
Merged

Mise en place d'un lock git - étape 1#4328
SebouChu merged 8 commits into
mainfrom
lock_send_to_git_step_1

Conversation

@pabois

@pabois pabois commented Sep 3, 2026

Copy link
Copy Markdown
Member

Type

  • Nouvelle fonctionnalité
  • Bug
  • Ajustement
  • Rangement

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

  • Incidence faible 😌
  • Incidence moyenne 😲
  • Incidence forte 😱

Changement d'interface

  • Aucun 😌
  • Changements mineurs 😲
  • Changments majeurs 😱

@pabois pabois changed the title Mise ne place d'un lock git - partie 1 Mise en place d'un lock git - partie 1 Sep 3, 2026
@pabois
pabois requested a lite review from Copilot September 3, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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_id to communication_websites (nullable FK to users, nullified on user deletion).
  • Implements lock state + lock/unlock helpers on websites, and propagates lock checks into Git::Repository and 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.

Comment thread app/services/git/repository.rb
Comment thread app/services/git/providers/abstract.rb Outdated
Comment thread app/services/git/repository.rb Outdated
Comment thread app/models/communication/website/with_git_repository.rb Outdated
Comment thread app/services/git/providers/github.rb
@arnaudlevy arnaudlevy changed the title Mise en place d'un lock git - partie 1 Mise en place d'un lock git Sep 7, 2026
@arnaudlevy arnaudlevy mentioned this pull request Sep 7, 2026
10 tasks
@SebouChu SebouChu changed the title Mise en place d'un lock git Mise en place d'un lock git - étape 1 Sep 7, 2026
@SebouChu
SebouChu merged commit c671703 into main Sep 7, 2026
8 checks passed
@SebouChu
SebouChu deleted the lock_send_to_git_step_1 branch September 7, 2026 13:57
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.

4 participants