当前位置: 首页>>代码示例>>PHP>>正文


PHP Git::revParse方法代码示例

本文整理汇总了PHP中Git::revParse方法的典型用法代码示例。如果您正苦于以下问题:PHP Git::revParse方法的具体用法?PHP Git::revParse怎么用?PHP Git::revParse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Git的用法示例。


在下文中一共展示了Git::revParse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: git_tag

function git_tag($projectroot, $project, $hash)
{
    global $tpl;
    $cachekey = sha1($project) . "|" . $hash;
    $git = new Git($projectroot . $project);
    $hash = $git->revParse($hash);
    if (!$tpl->is_cached('tag.tpl', $cachekey)) {
        $head = git_read_head($git);
        $tpl->assign("head", sha1_hex($head));
        $tpl->assign("hash", sha1_hex($hash));
        $tag = git_read_tag($git, $hash);
        $tpl->assign("tag", $tag);
        if (isset($tag['author'])) {
            $ad = date_str($tag['epoch'], $tag['tz']);
            $tpl->assign("datedata", $ad);
        }
    }
    $tpl->display('tag.tpl', $cachekey);
}
开发者ID:akumpf,项目名称:gitphp-glip,代码行数:19,代码来源:display.git_tag.php

示例2: 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);
}
开发者ID:akumpf,项目名称:gitphp-glip,代码行数:40,代码来源:display.git_blob_plain.php

示例3: git_commit

function git_commit($projectroot, $project, $hash)
{
    global $tpl;
    $cachekey = sha1($project) . "|" . $hash;
    $git = new Git($projectroot . $project);
    $hash = $git->revParse($hash);
    if (!$tpl->is_cached('commit.tpl', $cachekey)) {
        $co = git_read_commit($git, $hash);
        $ad = date_str($co['author_epoch'], $co['author_tz']);
        $cd = date_str($co['committer_epoch'], $co['committer_tz']);
        if (isset($co['parent'])) {
            $a_tree = $git->getObject(sha1_bin($co['parent']))->getTree();
        } else {
            $a_tree = false;
        }
        $b_tree = $git->getObject(sha1_bin($co['tree']));
        $difftree = GitTree::diffTree($a_tree, $b_tree);
        ksort($difftree);
        $tpl->assign("hash", sha1_hex($hash));
        $tpl->assign("tree", $co['tree']);
        if (isset($co['parent'])) {
            $tpl->assign("parent", $co['parent']);
        }
        $tpl->assign("title", $co['title']);
        $refs = read_info_ref($git);
        if (isset($refs[$hash])) {
            $tpl->assign("commitref", $refs[$hash]);
        }
        $tpl->assign("author", $co['author']);
        $tpl->assign("adrfc2822", $ad['rfc2822']);
        $tpl->assign("adhourlocal", $ad['hour_local']);
        $tpl->assign("adminutelocal", $ad['minute_local']);
        $tpl->assign("adtzlocal", $ad['tz_local']);
        $tpl->assign("committer", $co['committer']);
        $tpl->assign("cdrfc2822", $cd['rfc2822']);
        $tpl->assign("cdhourlocal", $cd['hour_local']);
        $tpl->assign("cdminutelocal", $cd['minute_local']);
        $tpl->assign("cdtzlocal", $cd['tz_local']);
        $tpl->assign("id", $co['id']);
        $tpl->assign("parents", $co['parents']);
        $tpl->assign("comment", $co['comment']);
        $tpl->assign("difftreesize", count($difftree) + 1);
        $status_map = array(GitTree::TREEDIFF_ADDED => "A", GitTree::TREEDIFF_REMOVED => "D", GitTree::TREEDIFF_CHANGED => "M");
        $difftreelines = array();
        foreach ($difftree as $file => $diff) {
            $difftreeline = array();
            $difftreeline["from_mode"] = decoct($diff->old_mode);
            $difftreeline["to_mode"] = decoct($diff->new_mode);
            $difftreeline["from_mode_cut"] = substr(decoct($diff->old_mode), -4);
            $difftreeline["to_mode_cut"] = substr(decoct($diff->new_mode), -4);
            $difftreeline["from_id"] = sha1_hex($diff->old_obj);
            $difftreeline["to_id"] = sha1_hex($diff->new_obj);
            $difftreeline["status"] = $status_map[$diff->status];
            $difftreeline["similarity"] = "";
            $difftreeline["file"] = $file;
            $difftreeline["from_file"] = "";
            $difftreeline["from_filetype"] = "";
            $difftreeline["to_file"] = "";
            $difftreeline["to_filetype"] = "";
            $difftreeline["isreg"] = TRUE;
            $modestr = "";
            /*if ((octdec($regs[1]) & 0x17000) != (octdec($regs[2]) & 0x17000))
            			$modestr .= " from " . file_type($regs[1]) . " to " . file_type($regs[2]);
            		if ((octdec($regs[1]) & 0777) != (octdec($regs[2]) & 0777)) {
            			if ((octdec($regs[1]) & 0x8000) && (octdec($regs[2]) & 0x8000))
            				$modestr .= " mode: " . (octdec($regs[1]) & 0777) . "->" . (octdec($regs[2]) & 0777);
            			else if (octdec($regs[2]) & 0x8000)
            				$modestr .= " mode: " . (octdec($regs[2]) & 0777);*/
            $difftreeline["modechange"] = $modestr;
            $simmodechg = "";
            /*if ($regs[1] != $regs[2])
            		$simmodechg .= ", mode: " . (octdec($regs[2]) & 0777);*/
            $difftreeline["simmodechg"] = $simmodechg;
            $difftreelines[] = $difftreeline;
        }
        $tpl->assign("difftreelines", $difftreelines);
    }
    $tpl->display('commit.tpl', $cachekey);
}
开发者ID:akumpf,项目名称:gitphp-glip,代码行数:79,代码来源:display.git_commit.php

示例4: git_blob

function git_blob($projectroot, $project, $hash, $file, $hashbase)
{
    global $gitphp_conf, $tpl;
    $cachekey = sha1($project) . "|" . $hashbase . "|" . $hash . "|" . sha1($file);
    $git = new Git($projectroot . $project);
    if (isset($hash)) {
        $hash = $git->revParse($hash);
    }
    if (isset($hashbase)) {
        $hashbase = $git->revParse($hashbase);
    }
    if (!$tpl->is_cached('blob.tpl', $cachekey)) {
        $head = git_read_head($git);
        if (!isset($hashbase)) {
            $hashbase = $head;
        }
        if (!isset($hash) && isset($file)) {
            $hash = git_get_hash_by_path($git, $git->getObject($hashbase), $file, "blob");
        }
        $catout = $git->getObject($hash)->data;
        $tpl->assign("hash", sha1_hex($hash));
        $tpl->assign("hashbase", sha1_hex($hashbase));
        $tpl->assign("head", sha1_hex($head));
        if ($co = git_read_commit($git, $hashbase)) {
            $tpl->assign("fullnav", TRUE);
            $refs = read_info_ref($git);
            $tpl->assign("tree", $co['tree']);
            $tpl->assign("title", $co['title']);
            if (isset($file)) {
                $tpl->assign("file", $file);
            }
            if (isset($refs[$hashbase])) {
                $tpl->assign("hashbaseref", $refs[$hashbase]);
            }
        }
        $paths = git_path_trees($git, $git->getObject($hashbase), $file);
        $tpl->assign("paths", $paths);
        if ($gitphp_conf['filemimetype']) {
            $mime = file_mime($catout, $file);
            if ($mime) {
                $mimetype = strtok($mime, "/");
            }
        }
        if ($mimetype == "image") {
            $tpl->assign("mime", $mime);
            $tpl->assign("data", base64_encode($catout));
        } else {
            $usedgeshi = $gitphp_conf['geshi'];
            if ($usedgeshi) {
                $usedgeshi = FALSE;
                include_once $gitphp_conf['geshiroot'] . "geshi.php";
                if (class_exists("GeSHi")) {
                    $geshi = new GeSHi("", 'php');
                    if ($geshi) {
                        $lang = "";
                        if (isset($file)) {
                            $lang = $geshi->get_language_name_from_extension(substr(strrchr($file, '.'), 1));
                        }
                        if (isset($lang) && strlen($lang) > 0) {
                            $geshi->set_source($catout);
                            $geshi->set_language($lang);
                            $geshi->set_header_type(GESHI_HEADER_DIV);
                            $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                            $tpl->assign("geshiout", $geshi->parse_code());
                            $usedgeshi = TRUE;
                        }
                    }
                }
            }
            if (!$usedgeshi) {
                $lines = explode("\n", $catout);
                $tpl->assign("lines", $lines);
            }
        }
    }
    $tpl->display('blob.tpl', $cachekey);
}
开发者ID:akumpf,项目名称:gitphp-glip,代码行数:77,代码来源:display.git_blob.php

示例5: git_read_head

function git_read_head(Git $proj)
{
    return $proj->revParse("HEAD");
}
开发者ID:prince-mishra,项目名称:gitphp-glip,代码行数:4,代码来源:glip.git_read_head.php


注:本文中的Git::revParse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。