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; }
private static function recurseParents(Commit $commit) { $parents = $commit->getParents(); $ret = array($commit); foreach ($parents as $parent) { $ret = array_merge($ret, self::recurseParents($parent)); } return $ret; }
/** * Writes the symbolic reference and the object it points to to disk * @param \gihp\IO\IOInterface $io */ public function write(\gihp\IO\IOInterface $io) { $io->moveHead($this); $this->head->write($io); }