コード例 #1
0
 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());
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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));
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
ファイル: CommitMessageTest.php プロジェクト: ibou77/elgg
    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));
    }