コード例 #1
0
ファイル: Changelog.php プロジェクト: silverstripe/cow
 /**
  * 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
ファイル: ChangelogLibrary.php プロジェクト: silverstripe/cow
 /**
  * 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
ファイル: CreateChangelog.php プロジェクト: silverstripe/cow
 /**
  * @param OutputInterface $output
  * @param ChangelogLibrary $changelogLibrary Changelog details
  * @param string $content content to save
  */
 protected function storeChangelog(OutputInterface $output, ChangelogLibrary $changelogLibrary, $content)
 {
     // Determine saving mechanism
     $version = $changelogLibrary->getRelease()->getVersion();
     $library = $changelogLibrary->getRelease()->getLibrary();
     $changelogHolder = $library->getChangelogHolder();
     // Store in local path
     $path = $library->getChangelogPath($version);
     if ($path) {
         // Generate header
         $fullPath = $changelogHolder->getDirectory() . '/' . $path;
         $existingContent = file_exists($fullPath) ? file_get_contents($fullPath) : null;
         $header = $this->getFileHeader($output, $version, $existingContent);
         // Write and commit changes
         $this->log($output, "Writing changelog to <info>{$fullPath}</info>");
         $dirname = dirname($fullPath);
         if (!is_dir($dirname)) {
             mkdir($dirname, 0777, true);
         }
         file_put_contents($fullPath, $header . $content);
         $this->commitChanges($output, $changelogHolder, $version, $fullPath);
     }
     // Store in yml to later push to git
     if ($library->hasGithubChangelog()) {
         // Note that we skip file header for github changes (for simplicity)
         // Write and commit changes to .cow.plan.json
         $this->log($output, "Caching changelog to push to github");
         $changelogLibrary->getRelease()->setChangelog($content);
         $this->getProject()->saveCachedPlan($this->getReleasePlan());
     }
 }