public function filter(CommitMessage $message) { $filter = $this; $words = $this->parseWords($message->getMessage()); $wordsLen = count($words); for ($i = 0; $i < $wordsLen; $i += 2) { $words[$i] = $this->filterWord($message, $words[$i]); } $message->setMessage(implode($words)); }
public function filter(CommitMessage $message) { $filter = $this; $words = preg_split('/([ ,;\\"\'\\<\\>!\\?\\.\\(\\)\\[\\]\\r\\n\\t]+)/', $message->getMessage(), -1, PREG_SPLIT_DELIM_CAPTURE); $wordsLen = count($words); for ($i = 0; $i < $wordsLen; $i += 2) { $words[$i] = $this->filterWord($message, $words[$i]); } $message->setMessage(implode($words)); }
public function filter(CommitMessage $message) { $lines = explode("\n", $message->getMessage()); $lines = array_filter($lines, function ($line) { if (empty($line)) { return TRUE; } if ($line[0] != '#') { return TRUE; } return FALSE; }); $message->setMessage(implode("\n", $lines)); }
/** * Filter each word in the commit message separately. * * @param CommitMessage $message * @param $word * @return mixed */ public function filterWord(CommitMessage $message, $word) { if ($this->isIssueKey($word)) { $issue = $this->getIssue($word); if ($issue) { $title = $word . ': ' . $issue->getSummary(); } else { $title = $word . ':'; } $url = $this->createIssueUrl($word); // CRM-13872 - Workaround to avoid duplicate footnotes when amending a commit message if (strpos($message->getMessage(), $url) === FALSE) { $message->addLinkNote($url, $title); } } return $word; }