Skip to content

Commit

Permalink
Merge branch '1.15' into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 12, 2024
2 parents fabea3e + cc90b44 commit 930371a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ public function getInstallerVersion(
return $cmsMajor . '.x-dev';
}
sort($minorPortions);
$minorPortion = $minorPortions[count($minorPortions) - 1];
$installerVersion = $cmsMajor . '.' . $minorPortion;

// It's normal for new major versions branches to exist a year or more before the first release
// The corresponding minor version branch will not exist at this time
// Check that the minor version of the installer branches exists, if not, fallback to using the major
// Get data about which branches exist so we can avoid testing against non-existent branches
if ($installerBranchesJson) {
// this if for unit testing
$json = json_decode($installerBranchesJson);
Expand All @@ -119,14 +115,23 @@ public function getInstallerVersion(
$json = json_decode(file_get_contents('__installer_branches.json'));
}
$branches = array_column($json, 'name');
// using array_filter() instead of in_array() to ensure we get a strict equality check
// e.g. '6' and '6.0' are not equal
$branchExists = count(array_filter($branches, fn($branch) => $branch === $installerVersion));
if (!$branchExists) {
return $cmsMajor . '.x-dev';

// It's normal for new major versions branches to exist a year or more before the first release
// and also our unit tests don't get magically updated when we release new minor releases.
// The corresponding minor version branch may not exist.
// Check that the minor version of the installer branches exists, if not, fallback to using the major
foreach (array_reverse($minorPortions) as $minorPortion) {
$installerVersion = $cmsMajor . '.' . $minorPortion;
// using array_filter() instead of in_array() to ensure we get a strict equality check
// e.g. '6' and '6.0' are not equal
$branchExists = count(array_filter($branches, fn($branch) => $branch === $installerVersion));
if ($branchExists) {
return $installerVersion . '.x-dev';
}
}

return $installerVersion . '.x-dev';
// If there were no branches for any minor version, fall back to the next-minor branch
return $cmsMajor . '.x-dev';
}
}

Expand Down

0 comments on commit 930371a

Please sign in to comment.