/** * 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; }