本文整理汇总了PHP中Git::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Git::getObject方法的具体用法?PHP Git::getObject怎么用?PHP Git::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Git
的用法示例。
在下文中一共展示了Git::getObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: git_blob_plain
function git_blob_plain($projectroot, $project, $hash, $file)
{
global $gitphp_conf, $tpl;
$cachekey = sha1($project) . "|" . $hash . "|" . sha1($file);
$buffer = null;
$git = new Git($projectroot . $project);
$hash = $git->revParse($hash);
// XXX: Nasty hack to cache headers
if (!$tpl->is_cached('blobheaders.tpl', $cachekey)) {
if ($file) {
$saveas = $file;
} else {
$saveas = $hash . ".txt";
}
$buffer = $git->getObject($hash)->data;
if ($gitphp_conf['filemimetype']) {
$mime = file_mime($buffer, $file);
}
$headers = array();
if ($mime) {
$headers[] = "Content-type: " . $mime;
} else {
$headers[] = "Content-type: text/plain; charset=UTF-8";
}
$headers[] = "Content-disposition: inline; filename=\"" . $saveas . "\"";
$tpl->assign("blobheaders", serialize($headers));
}
$out = $tpl->fetch('blobheaders.tpl', $cachekey);
$returnedheaders = unserialize($out);
foreach ($returnedheaders as $i => $header) {
header($header);
}
if (!$tpl->is_cached('blobplain.tpl', $cachekey)) {
if (!$buffer) {
$buffer = $git->getObject($hash)->data;
}
$tpl->assign("blob", $buffer);
}
$tpl->display('blobplain.tpl', $cachekey);
}
示例2: Git
$user = NULL;
}
}
}
$view->user = $user;
// Git {{{1
$repo = new Git(Config::GIT_PATH);
$parts = explode('?', $_SERVER['REQUEST_URI'], 2);
assert(!strncmp($parts[0], Config::PATH, strlen(Config::PATH)));
$parts[0] = substr($parts[0], strlen(Config::PATH));
$tip = $repo->getTip(Config::GIT_BRANCH);
$commit = $tip;
if (isset($_GET['commit'])) {
$commit = sha1_bin($_GET['commit']);
}
$commit = $repo->getObject($commit);
$commit_id = sha1_hex($commit->getName());
$view->commit_id = $commit_id;
$link_to_tip = !isset($_GET['commit']);
$commit_is_tip = $commit->getName() == $tip;
$view->commit_is_tip = $commit_is_tip;
$view->n_conflicts = count(ls_r(sprintf('%s/refs/heads/%s', Config::GIT_PATH, Config::GIT_CONFLICT_BRANCH_DIR)));
// URL parsing {{{1
$special = $page = NULL;
if (!strncmp($parts[0], '/:', 2)) {
$special = explode('/', substr($parts[0], 2), 2);
}
if ($special === NULL) {
$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action == '') {
$action = 'view';