function testMultipleLink() { $message = new CommitMessage("Hello\nworld\n"); $message->addLinkNote('http://example.com', 'Example'); $message->addLinkNote('http://example.org', 'Example For Good'); $message->addLinkNote('http://example.com', 'Example Redundant'); $this->assertEquals("Hello\nworld\n\n----------------------------------------\n* Example\n http://example.com\n* Example For Good\n http://example.org\n", $message->toString()); }
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 filterWord(CommitMessage $message, $word) { if (preg_match($this->wordPattern, $word)) { $issue = $this->getIssue($word); if ($issue) { $title = $word . ': ' . $issue->getSummary(); } else { $title = $word . ':'; } $message->addLinkNote($this->url . '/browse/' . $word, $title); } return $word; }
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; }
public function testRemovesComments() { $text = <<<___TEXT These are lines of text # this is a comment # and another one. And more text ___TEXT; $expected = "These are lines of text\nAnd more text"; $this->assertSame($expected, CommitMessage::removeComments($text)); }