コード例 #1
0
ファイル: CreateChangelog.php プロジェクト: silverstripe/cow
 /**
  * Generate changelog for this node only
  *
  * @param OutputInterface $output
  * @param LibraryRelease $release
  * @throws Exception
  */
 protected function generateChangelog(OutputInterface $output, LibraryRelease $release)
 {
     // Determine if this library has a changelog configured
     if (!$release->getLibrary()->hasChangelog()) {
         return;
     }
     // Get from version
     $fromVersion = $release->getPriorVersion();
     if (!$fromVersion) {
         $this->log($output, "No prior version for library <info>" . $release->getLibrary()->getName() . '</info>, ' . "skipping changelog for initial release");
         return;
     }
     $this->log($output, "Generating changelog for library <info>" . $release->getLibrary()->getName() . '</info>' . ' (<comment>' . $fromVersion->getValue() . '</comment> to ' . '<info>' . $release->getVersion()->getValue() . '</info>)');
     // Given a from version for this release, determine the "from" version for all child dependencies.
     // This does a deep search through composer dependencies and recursively checks out old versions
     // of composer.json to determine historic version information
     $changelogLibrary = $this->getChangelogLibrary($release, $fromVersion);
     // Preview diffs to generate for this changelog
     $count = $changelogLibrary->count();
     $this->log($output, "Found changes in <info>{$count}</info> modules:");
     foreach ($changelogLibrary->getAllItems(true) as $item) {
         $prior = $item->getPriorVersion()->getValue();
         $version = $item->getRelease()->getVersion()->getValue();
         $name = $item->getRelease()->getLibrary()->getName();
         $this->log($output, " * <info>{$name}</info> from <info>{$prior}</info> to <info>{$version}</info>");
     }
     // Generate markedown from plan
     $changelog = new Changelog($changelogLibrary);
     $content = $changelog->getMarkdown($output, $release->getLibrary()->getChangelogFormat());
     // Store this changelog
     $this->storeChangelog($output, $changelogLibrary, $content);
 }