Skip to content

Commit

Permalink
Merge pull request #17 from piwik/16_cut_off_patch_if_unknown
Browse files Browse the repository at this point in the history
When generating .travis.yml files, cut off a PHP version's patch if not known to exist on travis
  • Loading branch information
diosmosis committed Nov 18, 2015
2 parents ab737e8 + b63ed63 commit 7b908e3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class Generator
const DEFAULT_MINIMUM_PHP_VERSION_TO_TEST = '5.3.3';
const DEFAULT_MAXIMUM_PHP_VERSION_TO_TEST = '5.6';

private static $knownMinorPhpVersionsOnTravis = array('5.3.3');

/**
* @var string[]
*/
Expand Down Expand Up @@ -126,7 +128,8 @@ protected function configureView()
$this->view->setGenerateYmlCommand($thisConsoleCommand);

if (!empty($this->phpVersions)) {
$this->view->setPhpVersions($this->phpVersions);
$phpVersions = $this->getPhpVersionsKnownToExistOnTravis();
$this->view->setPhpVersions($phpVersions);
}

$outputYmlPath = $this->getTravisYmlOutputPath();
Expand Down Expand Up @@ -255,4 +258,24 @@ private function setMinimumPhpVersionFromPhpVersions()
usort($phpVersions, 'version_compare');
$this->minimumPhpVersion = reset($phpVersions);
}

private function getPhpVersionsKnownToExistOnTravis()
{
$self = $this;
return array_map(function ($version) use ($self) {
if (in_array($version, Generator::$knownMinorPhpVersionsOnTravis)
|| substr_count($version, ".") < 2
) {
return $version;
} else {
$parts = explode('.', $version, 3);
$parts = array($parts[0], $parts[1]);
$versionWithoutPatch = implode('.', $parts);

$self->log("info", "Version '$version' is not known to be available on travis, using '$versionWithoutPatch'.");

return $versionWithoutPatch;
}
}, $this->phpVersions);
}
}

0 comments on commit 7b908e3

Please sign in to comment.