/** * 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 * @return void */ protected function warnAboutErrors(Payload $payload) { $message = '#### This is an automated comment based on an automated formal commit review.'; $message .= PHP_EOL . PHP_EOL; $message .= 'Your pull request contains formal errors. Comments have been assigned to each commit in your pull request - '; $message .= 'please review and adjust. Feel free to ask for help if you need it!'; $payload->storePullRequestComment($payload->getPullRequest(), $message); }