diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 085ce2f35538f1299d7222f45f229b2631e0592a..d4f600641c7dae26020f4c1fce3184fecb171db2 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -24,6 +24,12 @@ services: - '@update.manager' tags: - { name: event_subscriber } + automatic_updates.excluded_paths_subscriber: + class: Drupal\automatic_updates\Event\ExcludedPathsSubscriber + arguments: + - '@extension.list.module' + tags: + - { name: event_subscriber } automatic_updates.staged_projects_validator: class: Drupal\automatic_updates\Validator\StagedProjectsValidator arguments: @@ -64,9 +70,3 @@ services: class: Drupal\automatic_updates\Validator\CoreComposerValidator tags: - { name: event_subscriber } - automatic_updates.excluded_paths_subscriber: - class: Drupal\automatic_updates\Event\ExcludedPathsSubscriber - arguments: - - '@extension.list.module' - tags: - - { name: event_subscriber } diff --git a/src/Event/ExcludedPathsSubscriber.php b/src/Event/ExcludedPathsSubscriber.php index ecc4b0ce68b5ab8f9916e202ff40e192e1a8f7b8..bb0eda80872a2e2251afbe92c75b36ed5a0f2348 100644 --- a/src/Event/ExcludedPathsSubscriber.php +++ b/src/Event/ExcludedPathsSubscriber.php @@ -2,12 +2,13 @@ namespace Drupal\automatic_updates\Event; +use Drupal\automatic_updates\Updater; use Drupal\Core\Extension\ModuleExtensionList; use Drupal\package_manager\Event\PreCreateEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * Defines an event subscriber to exclude certain paths from staging areas. + * Defines an event subscriber to exclude certain paths from update operations. */ class ExcludedPathsSubscriber implements EventSubscriberInterface { @@ -29,14 +30,15 @@ class ExcludedPathsSubscriber implements EventSubscriberInterface { } /** - * Excludes paths from a staging area before it is created. + * Reacts to the beginning of an update process. * * @param \Drupal\package_manager\Event\PreCreateEvent $event * The event object. */ public function preCreate(PreCreateEvent $event): void { - // If this module is a git clone, exclude it. - if (is_dir(__DIR__ . '/../../.git')) { + // If we are doing an automatic update and this module is a git clone, + // exclude it. + if ($event->getStage() instanceof Updater && is_dir(__DIR__ . '/../../.git')) { $dir = $this->moduleList->getPath('automatic_updates'); $event->excludePath($dir); }