/** * Commit changes to git * * @param OutputInterface $output * @param Library $library * @param Version $version * @param string $path */ public function commitChanges(OutputInterface $output, Library $library, Version $version, $path) { $repo = $library->getRepository(); $versionName = $version->getValue(); $repo->run("add", array($path)); $status = $repo->run("status"); if (stripos($status, 'Changes to be committed:')) { $repo->run("commit", array("-m", "Added {$versionName} changelog")); } }
/** * @param OutputInterface $output * @param Library $parentLibrary * @param array $composerData */ protected function updateComposerData(OutputInterface $output, Library $parentLibrary, array $composerData) { $parentName = $parentLibrary->getName(); $this->log($output, "Rewriting composer.json for <info>{$parentName}</info>"); // Write to filesystem $parentLibrary->setComposerData($composerData); // Commit to git $path = $parentLibrary->getComposerPath(); $repo = $parentLibrary->getRepository(); $repo->run("add", [$path]); $status = $repo->run("status"); if (stripos($status, 'Changes to be committed:')) { $repo->run("commit", ["-m", "Update development dependencies"]); } }
/** * Remove composer alias from composer.json * * @param OutputInterface $output * @param Library $library */ protected function removeComposerAlias(OutputInterface $output, Library $library) { // Check if there is any alias to remove $composerData = $library->getComposerData(); if (empty($composerData['extra']['branch-alias'])) { return; } $this->log($output, "Removing branch alias from <info>" . $library->getName() . "</info>"); unset($composerData['extra']['branch-alias']); // Write changes $path = $library->getComposerPath(); $library->setComposerData($composerData); // Commit to git $repo = $library->getRepository(); $repo->run("add", array($path)); $status = $repo->run("status"); if (stripos($status, 'Changes to be committed:')) { $repo->run("commit", array("-m", "Remove obsolete branch-alias")); } }