/** * 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); }