public function testURLParsing() { $shouldMatchURLs = array('https://github.com/silverstripe/deploynaut.git', 'github.com:silverstripe/deploynaut.git', 'git@github.com:silverstripe/deploynaut.git', 'ssh://git@github.com:22/silverstripe/deploynaut.git'); $project = new DNProject(); foreach ($shouldMatchURLs as $url) { $project->CVSPath = $url; $repositoryInterface = $project->getRepositoryInterface(); $this->assertEquals('https://github.com/silverstripe/deploynaut', $repositoryInterface->URL, "Failed to extract repository from " . $url); } $shouldntMatchURLs = array('https://othersite.com/github.com/ranking'); foreach ($shouldntMatchURLs as $url) { $project->CVSPath = $url; $repositoryInterface = $project->getRepositoryInterface(); $this->assertNull($repositoryInterface); } }
/** * @var array * @return \DeploymentStrategy */ protected function createStrategy($options) { $strategy = $this->environment->Backend()->planDeploy($this->environment, $options); $data = $strategy->toArray(); $interface = $this->project->getRepositoryInterface(); if ($interface instanceof \ArrayData && $this->canCompareCodeVersions($interface, $data['changes'])) { $compareurl = sprintf('%s/compare/%s...%s', $interface->URL, $data['changes']['Code version']['from'], $data['changes']['Code version']['to']); $data['changes']['Code version']['compareUrl'] = $compareurl; // special case for .platform.yml field so we don't show a huge blob of changes, // but rather a link to where the .platform.yml changes were made in the code if (isset($data['changes']['.platform.yml other'])) { $data['changes']['.platform.yml other']['compareUrl'] = $compareurl; $data['changes']['.platform.yml other']['description'] = ''; } } $this->extend('updateDeploySummary', $data); // Ensure changes that would have been updated are persisted in the object, // such as the comparison URL, so that they will be written to the Strategy // field on the DNDeployment object as part of {@link createDeployment()} $strategy->setChanges($data['changes']); return $strategy; }