コード例 #1
0
 /**
  * Get a commit
  *
  * @param string $hash commit hash
  * @return GitPHP_Commit|null commit objet
  */
 public function GetCommit($hash)
 {
     if (empty($hash)) {
         return null;
     }
     if (preg_match('/^[0-9A-Fa-f]{4,39}$/', $hash)) {
         $fullHash = $this->project->ExpandHash($hash);
         if ($fullHash == $hash) {
             throw new GitPHP_InvalidHashException($hash);
         }
         $hash = $fullHash;
     }
     if (!preg_match('/^[0-9A-Fa-f]{40}$/', $hash)) {
         return null;
     }
     $key = GitPHP_Commit::CacheKey($this->project->GetProject(), $hash);
     $commit = null;
     if ($this->memoryCache) {
         $commit = $this->memoryCache->Get($key);
     }
     if (!$commit) {
         if ($this->cache) {
             $commit = $this->cache->Get($key);
         }
         $strategy = null;
         if ($this->compat) {
             $strategy = new GitPHP_CommitLoad_Git($this->exe);
         } else {
             $strategy = new GitPHP_CommitLoad_Raw($this->objectLoader, $this->exe);
         }
         if ($commit) {
             $commit->SetProject($this->project);
             $commit->SetStrategy($strategy);
         } else {
             $commit = new GitPHP_Commit($this->project, $hash, $strategy);
         }
         $commit->AddObserver($this);
         if ($this->memoryCache) {
             $this->memoryCache->Set($key, $commit);
         }
     }
     return $commit;
 }
コード例 #2
0
ファイル: Commit.class.php プロジェクト: fboender/gitphp
 /**
  * Gets the cache key to use for this object
  *
  * @return string cache key
  */
 public function GetCacheKey()
 {
     return GitPHP_Commit::CacheKey($this->project->GetProject(), $this->hash);
 }