Example #1
0
 /**
  * ReadContentsGit
  *
  * Reads the tree contents using the git executable
  *
  * @access private
  */
 private function ReadContentsGit()
 {
     $exe = new GitPHP_GitExe($this->GetProject());
     $args = array();
     $args[] = '--full-name';
     if ($exe->CanShowSizeInTree()) {
         $args[] = '-l';
     }
     $args[] = '-t';
     $args[] = $this->hash;
     $lines = explode("\n", $exe->Execute(GIT_LS_TREE, $args));
     foreach ($lines as $line) {
         if (preg_match("/^([0-9]+) (.+) ([0-9a-fA-F]{40})(\\s+[0-9]+|\\s+-)?\t(.+)\$/", $line, $regs)) {
             switch ($regs[2]) {
                 case 'tree':
                     $t = $this->GetProject()->GetTree($regs[3]);
                     $t->SetMode($regs[1]);
                     $path = $regs[5];
                     if (!empty($this->path)) {
                         $path = $this->path . '/' . $path;
                     }
                     $t->SetPath($path);
                     if ($this->commit) {
                         $t->SetCommit($this->commit);
                     }
                     $this->contents[] = $t;
                     break;
                 case 'blob':
                     $b = $this->GetProject()->GetBlob($regs[3]);
                     $b->SetMode($regs[1]);
                     $path = $regs[5];
                     if (!empty($this->path)) {
                         $path = $this->path . '/' . $path;
                     }
                     $b->SetPath($path);
                     $size = trim($regs[4]);
                     if (!empty($size)) {
                         $b->SetSize($regs[4]);
                     }
                     if ($this->commit) {
                         $b->SetCommit($this->commit);
                     }
                     $this->contents[] = $b;
                     break;
             }
         }
     }
 }