protected function importMigrationLogFromGitHistory($commitChanges = false) { if (isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) { return null; } $migrationCommitMessages = Git::getLog($this->currentPackageData['path'], 'Migration:'); $appliedMigrationIdentifiers = []; foreach ($migrationCommitMessages as $commitMessage) { if (preg_match('/^\\s*Migration\\:\\s?([^\\s]*)/', $commitMessage, $matches) === 1) { $appliedMigrationIdentifiers[] = $matches[1]; } } if ($appliedMigrationIdentifiers === array()) { return null; } if (!isset($this->currentPackageData['composerManifest']['extra'])) { $this->currentPackageData['composerManifest']['extra'] = []; } $this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_unique($appliedMigrationIdentifiers); $this->writeComposerManifest(); $this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_values(array_unique($appliedMigrationIdentifiers)); $composerFilePathAndName = Files::concatenatePaths([$this->currentPackageData['path'], 'composer.json']); Tools::writeComposerManifest($this->currentPackageData['composerManifest'], $composerFilePathAndName); if ($commitChanges) { $commitMessageSubject = 'TASK: Import core migration log to composer.json'; if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) { $commitMessageSubject .= sprintf(' of "%s"', $this->currentPackageData['packageKey']); } $commitMessage = $commitMessageSubject . chr(10) . chr(10); $commitMessage .= wordwrap('This commit imports the core migration log to the "extra" section of the composer manifest.', 72); list($returnCode, $output) = Git::commitAll($this->currentPackageData['path'], $commitMessage); if ($returnCode === 0) { return ' ' . implode(PHP_EOL . ' ', $output) . PHP_EOL; } else { return ' No changes were committed.' . PHP_EOL; } } }