/** * * @return SS_HTTPResponse */ protected function createFetch() { $fetch = DNGitFetch::create(); $fetch->ProjectID = $this->record->ID; $fetch->write(); $fetch->start(); $location = Director::absoluteBaseURL() . $this->Link() . '/fetch/' . $fetch->ID; $output = array('message' => 'Ping queued as job ' . $fetch->ResqueToken, 'href' => $location); $response = $this->getAPIResponse($output); $response->setStatusCode(201); $response->addHeader('Location', $location); return $response; }
/** * Setup a job to clone a git repository. * @return string resque token */ public function cloneRepo() { // Avoid this being called multiple times in the same request if (!isset(self::$has_cloned_cache[$this->ID])) { $fetch = DNGitFetch::create(); $fetch->ProjectID = $this->ID; $fetch->write(); // passing true here tells DNGitFetch to force a git clone, otherwise // it will just update the repo if it already exists. We want to ensure // we're always cloning a new repo in this case, as the git URL may have changed. $fetch->start(true); self::$has_cloned_cache[$this->ID] = true; } }
/** * @return SS_HTTPResponse */ protected function createUpdate() { /** @var DNGitFetch $fetch */ $fetch = DNGitFetch::create(); $fetch->ProjectID = $this->project->ID; $fetch->write(); $fetch->start(); $location = Director::absoluteBaseURL() . $this->Link() . '/update/' . $fetch->ID; $output = ['message' => 'git fetch has been queued', 'id' => $fetch->ID, 'location' => $location]; $response = $this->getAPIResponse($output, 201); $response->addHeader('Location', $location); return $response; }