示例#1
0
 public function parse()
 {
     $data = $this->getClient()->run($this->getRepository(), 'ls-tree -l ' . $this->getHash());
     $lines = explode("\n", $data);
     $files = array();
     $root = array();
     foreach ($lines as $key => $line) {
         if (empty($line)) {
             unset($lines[$key]);
             continue;
         }
         $files[] = preg_split("/[\\s]+/", $line, 5);
     }
     foreach ($files as $file) {
         if ($file[1] == 'commit') {
             // submodule
             continue;
         }
         if ($file[0] == '120000') {
             $show = $this->getClient()->run($this->getRepository(), 'show ' . $file[2]);
             $tree = new Symlink();
             $tree->setMode($file[0]);
             $tree->setName($file[4]);
             $tree->setPath($show);
             $root[] = $tree;
             continue;
         }
         if ($file[1] == 'blob') {
             $blob = new Blob($file[2], $this->getClient(), $this->getRepository());
             $blob->setMode($file[0]);
             $blob->setName($file[4]);
             $blob->setSize($file[3]);
             $root[] = $blob;
             continue;
         }
         $tree = new Tree($file[2], $this->getClient(), $this->getRepository());
         $tree->setMode($file[0]);
         $tree->setName($file[4]);
         $root[] = $tree;
     }
     $this->data = $root;
 }
示例#2
0
 /**
  * Get the Tree for the provided folder
  * 
  * @param string $tree Folder that will be parsed
  * @return Tree Instance of Tree for the provided folder
  */
 public function getTree($tree)
 {
     $tree = new Tree($tree, $this->getClient(), $this);
     $tree->parse();
     return $tree;
 }