Пример #1
0
 /**
  * Place a comment using the configured comment plus
  * a dump of payload data from the Payload. Set the
  * comment for a pull request or commit as determined
  * by the OPTION_PULL_REQUEST and OPTION_COMMIT flags
  * (both of which are booleans).
  *
  * Both options can be set to TRUE, but if pull request
  * commenting is enabled, it takes priority. To comment
  * on the HEAD commit of a pull request, run this plugin
  * with only the OPTION_COMMIT flag.
  *
  * @param Payload $payload
  * @return void
  */
 public function process(Payload $payload)
 {
     $commentSetting = $this->getSetting(self::OPTION_COMMENT);
     if (FALSE === empty($commentSetting)) {
         $commentSetting .= PHP_EOL;
     }
     $errors = $payload->getResponse()->getErrors();
     $output = $payload->getResponse()->getOutput();
     $commentString = $commentSetting . $this->renderErrorsAsMarkupList($errors) . $this->renderPayloadDataAsMarkupList($output);
     $commentString = trim($commentString);
     if (TRUE === (bool) $this->getSettingValue(self::OPTION_PULL_REQUEST, FALSE)) {
         $payload->storePullRequestComment($payload->getPullRequest(), $commentString);
     } elseif (TRUE === (bool) $this->getSettingValue(self::OPTION_COMMIT, FALSE)) {
         $payload->storeCommitComment($payload->getHead(), $commentString);
     }
 }
 /**
  * @param Payload $payload
  * @param Commit $commit
  * @return boolean
  */
 protected function validateCommitMessage(Payload $payload, Commit $commit)
 {
     $messageResult = $this->commitMessageContainsValidPrefix($commit);
     if (TRUE !== $messageResult) {
         $payload->getResponse()->addOutputFromPlugin($this, array($messageResult));
         $payload->storeCommitComment($commit, $messageResult);
         $this->markCommit($payload, $commit, $messageResult);
         return FALSE;
     }
     return TRUE;
 }