/** * @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"]); } }
/** * 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")); } }
/** * Create a child library * * @param string $path * @return Library */ protected function createChildLibrary($path) { if (Module::isModulePath($path)) { return new Module($path, $this); } if (Library::isLibraryPath($path)) { return new Library($path, $this); } return null; }
/** * 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")); } }
/** * Propose a new version to tag for a given dependency * * @param LibraryRelease $parentRelease * @param Library $childModule * @return mixed|Version * @throws Exception */ protected function proposeNewReleaseVersion(LibraryRelease $parentRelease, Library $childModule) { // Get tags and composer constraint to filter by $tags = $childModule->getTags(); $constraint = $parentRelease->getLibrary()->getChildConstraint($childModule->getName(), $parentRelease->getVersion()); // Upgrade to self.version if ($constraint->isSelfVersion()) { $candidateVersion = $parentRelease->getVersion(); // If this is already tagged, just upgrade without a new release if (array_key_exists($candidateVersion->getValue(), $tags)) { return new LibraryRelease($childModule, $candidateVersion); } // Build release return new LibraryRelease($childModule, $candidateVersion); } // Get stability to use for the new tag $useSameStability = $parentRelease->getLibrary()->isStabilityInherited($childModule); if ($useSameStability) { $stability = $parentRelease->getVersion()->getStability(); $stabilityVersion = $parentRelease->getVersion()->getStabilityVersion(); } else { $stability = ''; $stabilityVersion = null; } // Filter versions $candidates = $constraint->filterVersions($tags); $tags = Version::sort($candidates, 'descending'); // Determine which best tag to create (with the correct stability) $existingTag = reset($tags); if ($existingTag) { // Increment from to guess next version $version = $existingTag->getNextVersion($stability, $stabilityVersion); } else { // In this case, the lower bounds of the constraint isn't a valid tag, // so this is our new candidate $version = clone $constraint->getMinVersion(); $version->setStability($stability); $version->setStabilityVersion($stabilityVersion); } // Report new tag return new LibraryRelease($childModule, $version); }