/** * 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); } }
/** * Switch to repository root, pull and do composer update. * * @param Payload $payload * @return void */ public function process(Payload $payload) { $output = array(); $command = $this->getCommand(); // run composer update $this->invokeShellCommand($command, $output); $payload->getResponse()->addOutputFromPlugin($this, $output); }
/** * Perform whichever task the Plugin should perform based * on the payload's data. * * @param Payload $payload * @return void */ public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch()); $url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl()); $git = $this->resolveGitCommand(); $command = array('cd', escapeshellarg($directory), '&&', $git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch)); if (TRUE === (bool) $this->getSettingValue(self::OPTION_REBASE, FALSE)) { $command[] = self::COMMAND_REBASE; } $output = $this->executeGitCommand($command); $payload->getResponse()->addOutputFromPlugin($this, $output); }
/** * @param Payload $payload */ public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $target = $this->getSettingValue(self::OPTION_HEAD); $git = $this->resolveGitCommand(); $command = array('cd', escapeshellarg($directory), '&&', $git, self::COMMAND); if (FALSE === empty($target)) { $command[] = $target; } if (TRUE === (bool) $this->getSettingValue(self::OPTION_HARD)) { $command[] = self::COMMAND_HARD; } $output = $this->executeGitCommand($command); $payload->getResponse()->addOutputFromPlugin($this, $output); }
/** * @param Payload $payload */ public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $directory = sprintf($directory, $payload->getRepository()->getName()); $git = $this->resolveGitCommand(); $branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch()); $track = $this->getSettingValue(self::OPTION_TRACK, FALSE); $noTrack = $this->getSettingValue(self::OPTION_NOTRACK, FALSE); $start = $this->getSettingValue(self::OPTION_STARTPOINT); $force = $this->getSettingValue(self::OPTION_FORCE, FALSE); $detach = $this->getSettingValue(self::OPTION_DETACH, FALSE); $orphan = $this->getSettingValue(self::OPTION_ORPHAN, FALSE); $newBranch = $this->getSettingValue(self::OPTION_NEWBRANCH, FALSE); $command = array($git, self::COMMAND); if (TRUE === $noTrack) { $command[] = self::COMMAND_NOTRACK; } elseif (TRUE === $track) { $trackBranch = $this->getSettingValue(self::OPTION_UPSTREAM, $payload->getRepository()->getMasterBranch()); $command[] = self::COMMAND_TRACK; $command[] = escapeshellarg($trackBranch); } if (TRUE === $force) { $command[] = self::COMMAND_FORCE; } if (TRUE === $orphan) { $command[] = self::COMMAND_ORPHAN; } if (TRUE === $detach) { $command[] = self::COMMAND_DETACH; } if (TRUE === $newBranch) { $command[] = self::COMMAND_NEWBRANCH; } $command[] = escapeshellarg($branch); if (NULL !== $start) { $command[] = escapeshellarg($start); } $output = array('Executing Git checkout command: ' . implode(' ', $command)); $output = array_merge($output, $this->executeGitCommand($command)); $payload->getResponse()->addOutputFromPlugin($this, $output); }
/** * @param Payload $payload */ public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(FALSE); $directory = sprintf($directory, $payload->getRepository()->getName()); $url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->resolveApiUrl(Repository::API_URL_CLONE)); $depth = $this->getSettingValue(self::OPTION_DEPTH, 0); $git = $this->resolveGitCommand(); $command = array($git, self::COMMAND); if (0 < $depth) { $command[] = self::COMMAND_DEPTH; $command[] = $depth; } if (TRUE === (bool) $this->getSettingValue(self::OPTION_SINGLE, FALSE)) { $command[] = self::COMMAND_SINGLEBRANCH; $command[] = self::COMMAND_BRANCH; $command[] = escapeshellarg($this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch())); } $command[] = escapeshellarg($url); $command[] = $directory; $output = array('Executing Git clone command: ' . implode(' ', $command)); $output = array_merge($output, $this->executeGitCommand($command)); $payload->getResponse()->addOutputFromPlugin($this, $output); }
/** * @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; }