/**
  * Gets a single tag
  *
  * @param string $tag tag to find
  * @param string $hash hash of tag, if known
  * @return GitPHP_Tag tag object
  */
 public function GetTag($tag, $hash = '')
 {
     if (empty($tag)) {
         return null;
     }
     $key = GitPHP_Tag::CacheKey($this->project->GetProject(), $tag);
     $tagObj = null;
     if ($this->memoryCache) {
         $tagObj = $this->memoryCache->Get($key);
     }
     if (!$tagObj) {
         if ($this->cache) {
             $tagObj = $this->cache->Get($key);
         }
         $strategy = null;
         if ($this->compat) {
             $strategy = new GitPHP_TagLoad_Git($this->exe);
         } else {
             $strategy = new GitPHP_TagLoad_Raw($this->objectLoader);
         }
         if ($tagObj) {
             $tagObj->SetProject($this->project);
             $tagObj->SetStrategy($strategy);
         } else {
             $tagObj = new GitPHP_Tag($this->project, $tag, $strategy, $hash);
         }
         $tagObj->AddObserver($this);
         if ($this->memoryCache) {
             $this->memoryCache->Set($key, $tagObj);
         }
     }
     return $tagObj;
 }
示例#2
0
 /**
  * Gets the cache key to use for this object
  *
  * @return string cache key
  */
 public function GetCacheKey()
 {
     return GitPHP_Tag::CacheKey($this->project->GetProject(), $this->refName);
 }