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;
}
}