Skip to content

Commit

Permalink
Fix having wrong update instruction order, when No updates are required
Browse files Browse the repository at this point in the history
  • Loading branch information
Natshah committed Dec 18, 2022
1 parent 5c4ffd2 commit 2603d31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Commands/VersionCheckComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function getVersion($type) {
print $versionInfo["current"];
break;
case "next":
if(isset($versionInfo['next'])){
if (isset($versionInfo['next'])) {
print $versionInfo["next"];
}
break;
Expand Down
18 changes: 11 additions & 7 deletions src/Helpers/VersionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,26 @@ public static function getVersionInfo($packages, $updateConfig, $latestVersions)

foreach ($updateConfig as $key => $conf) {
if (isset($conf["from"]) && isset($conf["to"])) {
$conf["from"] = preg_replace("/\*/", ".*", $conf["from"]);
$conf["to"] = preg_replace("/\*/", ".*", $conf["to"]);
$conf_from = preg_replace("/\*/", ".*", $conf["from"]);
$conf_to = preg_replace("/\*/", ".*", $conf["to"]);

foreach ($latestVersions as $key => $value) {
if (preg_match('/' . $conf['to'] . '/', $key)){
$conf["to"] = $key;
if (preg_match('/' . $conf_to . '/', $key)) {
$conf_to = $key;
break;
}
}

if (preg_match('/' . $conf['to'] . '/', $profileVersion)) {
if (preg_match('/' . $conf_to . '/', '/' . $conf_from . '/')) {
unset($versionInfo["next"]);
}

if (preg_match('/' . $conf_to . '/', $profileVersion)) {
continue;
}

if (preg_match('/' . $conf["from"] . '/', $profileVersion)) {
$versionInfo["next"] = $conf["to"];
if (preg_match('/' . $conf_from . '/', $profileVersion)) {
$versionInfo["next"] = $profileVersion;
}
}
}
Expand Down

0 comments on commit 2603d31

Please sign in to comment.