示例#1
0
 /**
  * Get the list of changes for this module
  *
  * @param OutputInterface $output
  * @param ChangelogLibrary $changelogLibrary
  * @return array
  */
 protected function getLibraryLog(OutputInterface $output, ChangelogLibrary $changelogLibrary)
 {
     $items = array();
     // Get raw log
     $fromVersion = $changelogLibrary->getPriorVersion()->getValue();
     $toVersion = $changelogLibrary->getRelease()->getIsNewRelease() ? 'HEAD' : $changelogLibrary->getRelease()->getVersion()->getValue();
     $range = $fromVersion . ".." . $toVersion;
     try {
         $log = $changelogLibrary->getRelease()->getLibrary()->getRepository()->getLog($range);
         foreach ($log->getCommits() as $commit) {
             $change = new ChangelogItem($changelogLibrary, $commit);
             // Skip ignored items
             if (!$change->isIgnored()) {
                 $items[] = $change;
             }
         }
     } catch (ReferenceNotFoundException $ex) {
         $moduleName = $changelogLibrary->getRelease()->getLibrary()->getName();
         $output->writeln("<error>Could not generate git diff for {$moduleName} for range {$range}; " . "Skipping changelog for this module</error>");
     }
     return $items;
 }
示例#2
0
 /**
  * Add or replace release for child object
  *
  * @param ChangelogLibrary $changelogLibrary
  * @return $this
  */
 public function addItem(ChangelogLibrary $changelogLibrary)
 {
     $name = $changelogLibrary->getRelease()->getLibrary()->getName();
     $this->items[$name] = $changelogLibrary;
     return $this;
 }
示例#3
0
 /**
  * Determine historic release plan from a past composer constraint
  *
  * @param LibraryRelease $newRelease
  * @param Version $historicVersion
  * @return ChangelogLibrary Changelog information for a library
  */
 protected function getChangelogLibrary(LibraryRelease $newRelease, Version $historicVersion)
 {
     // Build root release node
     $historicRelease = new ChangelogLibrary($newRelease, $historicVersion);
     // Check all dependencies from this past commit
     $pastComposer = null;
     foreach ($newRelease->getItems() as $childNewRelease) {
         // Lazy-load historic composer content as needed
         if (!isset($pastComposer)) {
             $pastComposer = $newRelease->getLibrary()->getHistoryComposerData($historicVersion);
         }
         // Check if this release has a historic tag.
         $childReleaseName = $childNewRelease->getLibrary()->getName();
         if (empty($pastComposer['require'][$childReleaseName])) {
             continue;
         }
         $historicConstraintName = $pastComposer['require'][$childReleaseName];
         // Get oldest existing tag that matches the given constraint as the "from" for changelog purposes.
         $historicConstraint = new ComposerConstraint($historicConstraintName, $historicVersion, $childReleaseName);
         $childVersions = $historicConstraint->filterVersions($childNewRelease->getLibrary()->getTags());
         // If "to" is stable, then filter out unstable "from"
         // E.g. prefer "3.4.0..3.4.1" over "3.4.0-rc1..3.4.1"
         if ($childNewRelease->getVersion()->isStable()) {
             $childVersions = Version::filter($childVersions, function (Version $nextTag) {
                 return $nextTag->isStable();
             });
         }
         // Get smallest matching version
         $childVersions = Version::sort($childVersions, Version::ASC);
         if (empty($childVersions)) {
             throw new \LogicException("No historic version for library {$childReleaseName} matches constraint {$historicConstraintName}");
         }
         // Check if to == from version
         $childHistoricVersion = reset($childVersions);
         if ($childHistoricVersion->getValue() === $childNewRelease->getVersion()->getValue()) {
             continue;
         }
         // Recursively generate historic tree
         $childChangelog = $this->getChangelogLibrary($childNewRelease, $childHistoricVersion);
         $historicRelease->addItem($childChangelog);
     }
     return $historicRelease;
 }