Exemple #1
0
 /**
  * testAuthor
  */
 public function testAuthor()
 {
     $author = new Author();
     $author->setEmail('*****@*****.**');
     $author->setName('foo');
     $this->assertEquals('*****@*****.**', $author->getEmail());
     $this->assertEquals('foo', $author->getName());
     $this->assertEquals('foo <*****@*****.**>', $author);
 }
Exemple #2
0
 /**
  * parse the output of a git command showing a commit
  *
  * @param array $outputLines output lines
  */
 private function parseOutputLines($outputLines)
 {
     $message = '';
     foreach ($outputLines as $line) {
         $matches = array();
         if (preg_match('/^commit (\\w+)$/', $line, $matches) > 0) {
             $this->sha = $matches[1];
         }
         if (preg_match('/^tree (\\w+)$/', $line, $matches) > 0) {
             $this->tree = $matches[1];
         }
         if (preg_match('/^parent (\\w+)$/', $line, $matches) > 0) {
             $this->parents[] = $matches[1];
         }
         if (preg_match('/^author (.*) <(.*)> (\\d+) (.*)$/', $line, $matches) > 0) {
             $author = new Author();
             $author->setName($matches[1]);
             $author->setEmail($matches[2]);
             $this->author = $author;
             $date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
             $date->modify($date->getOffset() . ' seconds');
             $this->datetimeAuthor = $date;
         }
         if (preg_match('/^committer (.*) <(.*)> (\\d+) (.*)$/', $line, $matches) > 0) {
             $committer = new Author();
             $committer->setName($matches[1]);
             $committer->setEmail($matches[2]);
             $this->committer = $committer;
             $date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
             $date->modify($date->getOffset() . ' seconds');
             $this->datetimeCommitter = $date;
         }
         if (preg_match('/^    (.*)$/', $line, $matches)) {
             $message[] = $matches[1];
         }
     }
     $this->message = new Message($message);
 }