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


PHP Git::getTypeID方法代码示例

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


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

示例1: _unserialize

 public function _unserialize($data)
 {
     $lines = explode("\n", $data);
     unset($data);
     $meta = array();
     while (($line = array_shift($lines)) != '') {
         $parts = explode(' ', $line, 2);
         if (!isset($meta[$parts[0]])) {
             $meta[$parts[0]] = array($parts[1]);
         } else {
             $meta[$parts[0]][] = $parts[1];
         }
     }
     if (isset($meta['object'][0])) {
         $this->object = sha1_bin($meta['object'][0]);
         $this->objtype = Git::getTypeID($meta['type'][0]);
     }
     if (isset($meta['tag'][0])) {
         $this->tag = $meta['tag'][0];
     }
     if (isset($meta['tagger'][0])) {
         $this->tagger = new GitCommitStamp();
         $this->tagger->unserialize($meta['tagger'][0]);
     }
     $this->summary = array_shift($lines);
     $this->detail = implode("\n", $lines);
 }
开发者ID:halstead,项目名称:glip,代码行数:27,代码来源:git_tag.class.php

示例2: getRawObject

 /**
  * @brief Fetch an object in its binary representation by name.
  *
  * Throws an exception if the object cannot be found.
  *
  * @param $objectName (string) name of the object (binary SHA1)
  * @returns (array) an array consisting of the object type (int) and the
  * binary representation of the object (string)
  */
 protected function getRawObject($objectName)
 {
     static $cache = array();
     /* FIXME allow limiting the cache to a certain size */
     if (isset($cache[$objectName])) {
         return $cache[$objectName];
     }
     $sha1 = Git::sha1Hex($objectName);
     $path = sprintf('%s/objects/%s/%s', $this->dir, substr($sha1, 0, 2), substr($sha1, 2));
     if (file_exists($path)) {
         list($hdr, $objectData) = explode("", gzuncompress(file_get_contents($path)), 2);
         sscanf($hdr, "%s %d", $type, $objectSize);
         $objectType = Git::getTypeID($type);
         $result = array($objectType, $objectData);
     } elseif ($packedObject = $this->findPackedObject($objectName)) {
         list($packName, $objectOffset) = $packedObject;
         $pack = fopen(sprintf('%s/objects/pack/pack-%s.pack', $this->dir, sha1Hex($packName)), 'rb');
         flock($pack, LOCK_SH);
         /* check magic and version */
         $magic = fread($pack, 4);
         $version = Binary::fuint32($pack);
         if ($magic != 'PACK' || $version != 2) {
             throw new Exception('unsupported pack format');
         }
         $result = $this->unpackObject($pack, $objectOffset);
         fclose($pack);
     } else {
         throw new Exception(sprintf('object not found: %s', sha1Hex($objectName)));
     }
     $cache[$objectName] = $result;
     return $result;
 }
开发者ID:Ennosuke,项目名称:glip,代码行数:41,代码来源:Git.php

示例3: getRawObject

 /**
  * @brief Fetch an object in its binary representation by name.
  *
  * Throws an exception if the object cannot be found.
  *
  * @param $object_name (string) name of the object (binary SHA1)
  * @returns (array) an array consisting of the object type (int) and the
  * binary representation of the object (string)
  */
 public function getRawObject($object_name)
 {
     static $cache = array();
     /* FIXME allow limiting the cache to a certain size */
     if (isset($cache[$object_name])) {
         return $cache[$object_name];
     }
     $sha1 = sha1_hex($object_name);
     $path = sprintf('%s/objects/%s/%s', $this->dir, substr($sha1, 0, 2), substr($sha1, 2));
     if (file_exists($path)) {
         list($hdr, $object_data) = explode("", gzuncompress(file_get_contents($path)), 2);
         sscanf($hdr, "%s %d", $type, $object_size);
         $object_type = Git::getTypeID($type);
         $r = array($object_type, $object_data);
     } else {
         if ($x = $this->findPackedObject($object_name)) {
             list($pack_name, $object_offset) = $x;
             $pack = fopen(sprintf('%s/objects/pack/pack-%s.pack', $this->dir, sha1_hex($pack_name)), 'rb');
             flock($pack, LOCK_SH);
             /* check magic and version */
             $magic = fread($pack, 4);
             $version = Binary::fuint32($pack);
             if ($magic != 'PACK' || $version != 2) {
                 throw new Exception('unsupported pack format');
             }
             $r = $this->unpackObject($pack, $object_offset);
             fclose($pack);
         }
     }
     // Try alternate repositories.
     foreach ($this->alternates as $alternate_dir) {
         try {
             $alternate_git = new Git($alternate_dir);
             $r = $alternate_git->getRawObject($object_name);
             break;
         } catch (Exception $e) {
         }
     }
     if (!isset($r)) {
         throw new Exception(sprintf('object not found: %s', sha1_hex($object_name)));
     }
     $cache[$object_name] = $r;
     return $r;
 }
开发者ID:halstead,项目名称:glip,代码行数:53,代码来源:git.class.php


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