Ejemplo n.º 1
0
 /**
  * Abbreviate a hash
  *
  * @param GitPHP_Project $project project
  * @param string $hash hash to abbreviate
  * @return string abbreviated hash
  */
 public function AbbreviateHash($project, $hash)
 {
     if (!$project) {
         return $hash;
     }
     if (!preg_match('/[0-9A-Fa-f]{40}/', $hash)) {
         return $hash;
     }
     $abbrevLen = GitPHP_ProjectLoad_Raw::HashAbbreviateLength;
     $projAbbrevLen = $project->GetAbbreviateLength();
     if ($projAbbrevLen > 0) {
         $abbrevLen = max(4, min($projAbbrevLen, 40));
     }
     $prefix = substr($hash, 0, $abbrevLen);
     if (!$project->GetUniqueAbbreviation()) {
         return $prefix;
     }
     return $this->objectLoader->EnsureUniqueHash($hash, $prefix);
 }