Esempio n. 1
0
 /**
  * Load a project's head hash
  *
  * @param GitPHP_Project $project
  * @return string head hash
  */
 public function LoadHead($project)
 {
     if (!$project) {
         return;
     }
     $headPointer = trim(file_get_contents($project->GetPath() . '/HEAD'));
     if (preg_match('/^([0-9A-Fa-f]{40})$/', $headPointer, $regs)) {
         /* Detached HEAD */
         return $regs[1];
     } else {
         if (preg_match('/^ref: (.+)$/', $headPointer, $regs)) {
             /* standard pointer to head */
             $head = substr($regs[1], strlen('refs/heads/'));
             if ($project->GetHeadList()->Exists($head)) {
                 return $project->GetHeadList()->GetHead($head)->GetHash();
             }
         }
     }
 }