public function verifyBase(\gihp\Object\Commit $commit) { $this->assertEqual($commit->getMessage(), 'New commit'); $this->assertIsA($commit->getAuthorTime(), '\\DateTime'); $this->assertIsA($commit->getAuthor(), '\\gihp\\Metadata\\Person'); $this->assertEqual($commit->getAuthor(), new \gihp\Metadata\Person('gihp', 'git@gihp')); $this->assertIsA($commit->getCommitter(), '\\gihp\\Metadata\\Person'); $this->assertIsA($commit->getCommitTime(), '\\DateTime'); $this->assertIsA($commit->getTree(), '\\gihp\\Object\\Tree'); }
/** * Exports a commit * @param \gihp\Object\Commit $commit * @return string */ private static function exportCommit(Commit $commit) { $data = 'tree ' . $commit->getTree()->getSHA1(); foreach ($commit->getParents() as $parent) { $data .= "\n" . 'parent ' . $parent->getSHA1(); } $data .= "\n" . 'author ' . $commit->getAuthor() . ' ' . $commit->getAuthorTime()->format('U O'); $data .= "\n" . 'committer ' . $commit->getCommitter() . ' ' . $commit->getCommitTime()->format('U O'); $data .= "\n\n" . $commit->getMessage(); return $data; }