From d3dce321e06503af617bcbf2fa08f1cb756834a1 Mon Sep 17 00:00:00 2001 From: Allan Chappell Date: Fri, 12 Apr 2024 15:30:33 -0500 Subject: [PATCH] adding diff command for remote exporting --- src/Commands/config/ConfigExportCommands.php | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Commands/config/ConfigExportCommands.php b/src/Commands/config/ConfigExportCommands.php index 50b2684310..defcc94b8b 100644 --- a/src/Commands/config/ConfigExportCommands.php +++ b/src/Commands/config/ConfigExportCommands.php @@ -215,4 +215,29 @@ public function validate($commandData): void } } } + + /** + * Display a diff of the active configuration set versus what's on disk. + * + * @command config:diff + * + * @usage drush config:diff + * Display a diff of the active configuration set versus what's on disk. + */ + public function diff(): string + { + $diff = ''; + $destination_dir = ConfigCommands::getDirectory(); + $sync_directory = Settings::get('config_sync_directory'); + // Prepare the configuration storage for the export. + if ($sync_directory !== null && $destination_dir == Path::canonicalize($sync_directory)) { + $target_storage = $this->getConfigStorageSync(); + $config_comparer = new StorageComparer($this->getConfigStorageExport(), $target_storage, $this->getConfigManager()); + if ($config_comparer->createChangelist()->hasChanges()) { + $diff = ConfigCommands::getDiff($target_storage, $this->getConfigStorageExport(), $this->output()); + $diff = preg_replace("/\033\[[^m]*m/", '', $diff); + } + } + return $diff; + } }