Neos\Flow\Core\Migrations\Git::getLog PHP Метод

getLog() публичный статический Метод

Returns the git log for the specified $path, optionally filtered for $searchTerm
public static getLog ( string $path, string $searchTerm = null ) : array
$path string
$searchTerm string optional term to filter the log for
Результат array
    public static function getLog($path, $searchTerm = null)
    {
        $output = array();
        chdir($path);
        if ($searchTerm !== null) {
            exec('git log -F --grep=' . escapeshellarg($searchTerm), $output);
        } else {
            exec('git log', $output);
        }
        return $output;
    }

Usage Example

Пример #1
0
 /**
  * Imports the core migration log from the git history if it has not been imported previously (the "applied-flow-migrations" composer manifest property does not exist)
  *
  * @param boolean $commitChanges if TRUE the modified composer manifest is committed - if it changed
  * @return string
  */
 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;
         }
     }
 }