public function makeChangelog($repository) {
      $repoPrefix = 'remotes/upstream/';
      $parentRevision = 'master';
      $currentRevision = 'develop';

      $changelog = $this->taskChangelog();
      $command = 'git describe --abbrev=0 --tags';
      $lastTag = $this->_exec($command)->getMessage();
      if ($lastTag) {
         // if tags exist check against the last one
         $parentRevision = 'tags/' . trim($lastTag);
      } else if (!$this->_exec("git ls-remote upstream $parentRevision")->getMessage()) {
         // master branch does not exist, let's go against first parent as first time ever revision check
         $message = $this->_exec("git rev-list --max-parents=0 HEAD")->getMessage();
         $parentRevision = trim($message);
         $currentRevision = 'HEAD';
      }

      // default revision range
      $fromRev = $repoPrefix . $parentRevision;
      $toRev = $repoPrefix . $currentRevision;
      if ($currentRevision == 'HEAD') {
         // first time ever revision check fix, prefix can't be used.
         $fromRev = $parentRevision;
         $toRev = $currentRevision;
      }

      $this->stopOnFail(true);
      $command = 'git log --pretty=" * %s ([%h](https://github.com/' . $repository . '/commit/%h))"  ' . $fromRev . '..' . $toRev . ' --grep="^fix" --grep="^feat" --grep=="^perf"';
      $result = $this->_exec($command)->getMessage();
      if (empty($result)) {
         return Robo\Result::cancelled('No new commits for release an update');
      }
      if (preg_match('/(BREAKING CHANGE:)|(^ \* feat)/m', $result, $regs)) {
         switch ($regs[0]) {
            case 'BREAKING CHANGE:':
               $this->releaseType = 'major';
               break;
            case ' * feat':
               $this->releaseType = 'minor';
               break;
            // by default is patch
         }
      }
      $this->setVersionFromComposer('composer.json');
      $newVersion = $this->newVersion = $this->generateNextVersion($this->version);
      $result = ($result) ? $result : ' * Minor changes, for more details see our [commit history](https://github.com/' . $repository . '/compare/master...' . $newVersion . '/bugfixes)';
      $changelog->filename('CHANGELOG.md')
         ->version("[" . $newVersion . "](https://github.com/$repository/tree/" . $newVersion . ") (" . date('Y-m-d') . ")")
         ->setBody($result)
         ->run();
   }
public function makeChangelog($repository) {
      $repoPrefix = 'remotes/upstream/';
      $parentRevision = 'master';
      $currentRevision = 'develop';

      $changelog = $this->taskChangelog();
      $command = 'git describe --abbrev=0 --tags';
      $lastTag = $this->_exec($command)->getMessage();
      if ($lastTag) {
         // if tags exist check against the last one
         $parentRevision = 'tags/' . trim($lastTag);
      } else if (!$this->_exec("git ls-remote upstream $parentRevision")->getMessage()) {
         // master branch does not exist, let's go against first parent as first time ever revision check
         $message = $this->_exec("git rev-list --max-parents=0 HEAD")->getMessage();
         $parentRevision = trim($message);
         $currentRevision = 'HEAD';
      }

      // default revision range
      $fromRev = $repoPrefix . $parentRevision;
      $toRev = $repoPrefix . $currentRevision;
      if ($currentRevision == 'HEAD') {
         // first time ever revision check fix, prefix can't be used.
         $fromRev = $parentRevision;
         $toRev = $currentRevision;
      }

      $this->stopOnFail(true);
      $command = 'git log --pretty=" * %s ([%h](https://github.com/' . $repository . '/commit/%h))"  ' . $fromRev . '..' . $toRev . ' --grep="^fix" --grep="^feat" --grep=="^perf"';
      $result = $this->_exec($command)->getMessage();
      if (empty($result)) {
         return Robo\Result::cancelled('No new commits for release an update');
      }
      if (preg_match('/(BREAKING CHANGE:)|(^ \* feat)/m', $result, $regs)) {
         switch ($regs[0]) {
            case 'BREAKING CHANGE:':
               $this->releaseType = 'major';
               break;
            case ' * feat':
               $this->releaseType = 'minor';
               break;
            // by default is patch
         }
      }
      $this->setVersionFromComposer('composer.json');
      $newVersion = $this->newVersion = $this->generateNextVersion($this->version);
      $result = ($result) ? $result : ' * Minor changes, for more details see our [commit history](https://github.com/' . $repository . '/compare/master...' . $newVersion . '/bugfixes)';
      $changelog->filename('CHANGELOG.md')
         ->version("[" . $newVersion . "](https://github.com/$repository/tree/" . $newVersion . ") (" . date('Y-m-d') . ")")
         ->setBody($result)
         ->run();
   }
public function makeChangelog ( $ repository ) { $ repoPrefix = 'remotes/upstream/' ; $ parentRevision = 'master' ; $ currentRevision = 'develop' ; $ changelog = $ this -> taskChangelog ( ) ; $ command = 'git describe --abbrev=0 --tags' ; $ lastTag = $ this -> _exec ( $ command ) -> getMessage ( ) ; if ( $ lastTag ) { // if tags exist check against the last one $ parentRevision = 'tags/' . trim ( $ lastTag ) ; } else if ( ! $ this -> _exec ( "git ls-remote upstream $parentRevision" ) -> getMessage ( ) ) { // master branch does not exist, let's go against first parent as first time ever revision check $ message = $ this -> _exec ( "git rev-list --max-parents=0 HEAD" ) -> getMessage ( ) ; $ parentRevision = trim ( $ message ) ; $ currentRevision = 'HEAD' ; } // default revision range $ fromRev = $ repoPrefix . $ parentRevision ; $ toRev = $ repoPrefix . $ currentRevision ; if ( $ currentRevision == 'HEAD' ) { // first time ever revision check fix, prefix can't be used. $ fromRev = $ parentRevision ; $ toRev = $ currentRevision ; } $ this -> stopOnFail ( true ) ; $ command = 'git log --pretty=" * %s ([%h](https://github.com/' . $ repository . '/commit/%h))"  ' . $ fromRev . '..' . $ toRev . ' --grep="^fix" --grep="^feat" --grep=="^perf"' ; $ result = $ this -> _exec ( $ command ) -> getMessage ( ) ; if ( empty ( $ result ) ) { return Robo \ Result :: cancelled ( 'No new commits for release an update' ) ; } if ( preg_match ( '/(BREAKING CHANGE:)|(^ \* feat)/m' , $ result , $ regs ) ) { switch ( $ regs [ 0 ] ) { case 'BREAKING CHANGE:' : $ this -> releaseType = 'major' ; break ; case ' * feat' : $ this -> releaseType = 'minor' ; break ; // by default is patch } } $ this -> setVersionFromComposer ( 'composer.json' ) ; $ newVersion = $ this -> newVersion = $ this -> generateNextVersion ( $ this -> version ) ; $ result = ( $ result ) ? $ result : ' * Minor changes, for more details see our [commit history](https://github.com/' . $ repository . '/compare/master...' . $ newVersion . '/bugfixes)' ; $ changelog -> filename ( 'CHANGELOG.md' ) -> version ( "[" . $ newVersion . "](https://github.com/$repository/tree/" . $ newVersion . ") (" . date ( 'Y-m-d' ) . ")" ) -> setBody ( $ result ) -> run ( ) ; }
Task to create the changelog of the project
@param string $repository name
@return \Robo\Result|\Robo\ResultData
@throws Exception
Task to create the changelog of the project