Skip to content

Commit

Permalink
FIX Move parent branch logic
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jul 11, 2022
1 parent c6dca88 commit e216d93
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class JobCreator
public function getInstallerVersion(): string
{
$repo = explode('/', $this->githubRepository)[1];
// repo should not use installer
if (in_array($repo, NO_INSTALLER_LOCKSTEPPED_REPOS) || in_array($repo, NO_INSTALLER_UNLOCKSTEPPED_REPOS)) {
return '';
}
$branch = $this->getCleanedBranch();
$cmsMajor = $this->getCmsMajorFromBranch();
// module is a lockstepped repo
// repo is a lockstepped repo
if (in_array($repo, LOCKSTEPPED_REPOS) && is_numeric($branch)) {
// e.g. ['4', '11']
$portions = explode('.', $branch);
Expand All @@ -31,11 +32,7 @@ public function getInstallerVersion(): string
return $cmsMajor . '.' . $portions[1] . '.x-dev';
}
}
// use the parent branch
if ($this->parentBranch && is_numeric($this->parentBranch)) {
return $this->parentBranch . '.x-dev';
}
// use the latest minor version of installer
// fallback to use the latest minor version of installer
$installerVersions = array_keys(INSTALLER_TO_PHP_VERSIONS);
$installerVersions = array_filter($installerVersions, fn($version) => substr($version, 0, 1) === $cmsMajor);
// remove major versions
Expand Down Expand Up @@ -117,6 +114,10 @@ private function getCleanedBranch(): string
if (preg_match('#^pulls/([0-9\.]+)/#', $branch, $matches)) {
$branch = $matches[1];
}
// fallback to parent branch if available
if (!is_numeric($branch) && $this->parentBranch && is_numeric($this->parentBranch)) {
$branch = $this->parentBranch;
}
// e.g. 4.10-release
$branch = preg_replace('#^([0-9\.]+)-release$#', '$1', $branch);
return $branch;
Expand Down

0 comments on commit e216d93

Please sign in to comment.