Neos\Flow\Core\Migrations\Git::commitAll PHP Method

commitAll() public static method

public static commitAll ( string $path, string $message ) : array
$path string
$message string
return array in the format [, '']
    public static function commitAll($path, $message)
    {
        chdir($path);
        exec('git add .');
        $output = array();
        $returnCode = null;
        $temporaryPathAndFilename = tempnam(sys_get_temp_dir(), 'flow-commitmsg');
        file_put_contents($temporaryPathAndFilename, $message);
        exec('git commit --allow-empty -F ' . escapeshellarg($temporaryPathAndFilename), $output, $returnCode);
        unlink($temporaryPathAndFilename);
        return array($returnCode, $output);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Commit changes done to the package described by $packageData. The migration
  * that was did the changes is given with $versionNumber and $versionPackageKey
  * and will be recorded in the commit message.
  *
  * @param AbstractMigration $migration
  * @param string $commitMessageNotice
  * @return string
  */
 protected function commitMigration(AbstractMigration $migration, $commitMessageNotice = null)
 {
     $migrationIdentifier = $migration->getIdentifier();
     $commitMessageSubject = sprintf('TASK: Apply migration %s', $migrationIdentifier);
     if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) {
         $commitMessageSubject .= sprintf(' to package "%s"', $this->currentPackageData['packageKey']);
     }
     $commitMessage = $commitMessageSubject . chr(10) . chr(10);
     $description = $migration->getDescription();
     if ($description !== null) {
         $commitMessage .= wordwrap($description, 72);
     } else {
         $commitMessage .= wordwrap(sprintf('This commit contains the result of applying migration %s to this package.', $migrationIdentifier), 72);
     }
     if ($commitMessageNotice !== null) {
         $commitMessage .= chr(10) . chr(10) . wordwrap($commitMessageNotice, 72) . chr(10) . chr(10);
     }
     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;
     }
 }