Esempio n. 1
0
 /**
  * @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"]);
     }
 }
Esempio n. 2
0
 /**
  * Do child releases inherit stability for the given library?
  *
  * @param Library $childLibrary Library to test for stability inheritance for
  * @return bool
  */
 public function isStabilityInherited(Library $childLibrary)
 {
     $cowData = $this->getCowData();
     if (empty($cowData['child-stability-inherit'])) {
         return false;
     }
     // Check if only some modules inherit stability
     if (is_array($cowData['child-stability-inherit'])) {
         return in_array($childLibrary->getName(), $cowData['child-stability-inherit']);
     }
     return true;
 }
 /**
  * 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"));
     }
 }
Esempio n. 4
0
 /**
  * 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);
 }