clearGitCache() публичный Метод

This will clear the cache for the git getters and should be called when the local git repo is updated
public clearGitCache ( )
Пример #1
0
 public function perform()
 {
     set_time_limit(0);
     if (!empty($this->args['logfile'])) {
         $this->log = new DeploynautLogFile($this->args['logfile']);
     }
     $this->project = DNProject::get()->byId($this->args['projectID']);
     if (!($this->project && $this->project->exists())) {
         throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID']));
     }
     $this->user = DNData::inst()->getGitUser() ?: null;
     // Disallow concurrent git fetches on the same project.
     // Only consider fetches started in the last 30 minutes (older jobs probably got stuck)
     try {
         if (!empty($this->args['fetchID'])) {
             $runningFetches = DNGitFetch::get()->filter(array('ProjectID' => $this->project->ID, 'Status' => array('Queued', 'Started'), 'Created:GreaterThan' => strtotime('-30 minutes')))->exclude('ID', $this->args['fetchID']);
             if ($runningFetches->count()) {
                 $runningFetch = $runningFetches->first();
                 $message = sprintf('Another fetch is in progress (started at %s by %s)', $runningFetch->dbObject('Created')->Nice(), $runningFetch->Deployer()->Title);
                 if ($this->log) {
                     $this->log->write($message);
                 }
                 throw new RuntimeException($message);
             }
         }
         // Decide whether we need to just update what we already have
         // or initiate a clone if no local repo exists.
         if ($this->project->repoExists() && empty($this->args['forceClone'])) {
             $this->fetchRepo();
         } else {
             $this->cloneRepo();
         }
     } catch (Exception $e) {
         if ($this->log) {
             $this->log->write($e->getMessage());
         }
         throw $e;
     }
     $this->project->clearGitCache();
     $this->updateStatus('Finished');
 }