Make version comparision robust
This needed to take various git version into account as per https://github.com/LibreTime/libretime/pull/102#issuecomment-288707322. It also had a bug where it would do the completely wrong thing with the currentParts array if a git commit-ish was treated as a version by mistake.
This commit is contained in:
parent
01aef516e4
commit
42e0d40e62
1 changed files with 5 additions and 2 deletions
|
@ -23,11 +23,14 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract {
|
|||
$latest = Application_Model_Preference::GetLatestVersion();
|
||||
$link = Application_Model_Preference::GetLatestLink();
|
||||
|
||||
$isGitRelease = preg_match('/^[[:alnum:]]{7}$/i', $current) === 1;
|
||||
$currentParts = array(0, 0, 0, 0);
|
||||
$isGitRelease = preg_match('/^[[:alnum:]]{7,}$/i', $current) === 1;
|
||||
$currentParts = array();
|
||||
if (!$isGitRelease) {
|
||||
$currentParts = preg_split("/(\.|-)/", $current);
|
||||
}
|
||||
if (count($currentParts) < 3) {
|
||||
$currentParts = array(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
$majorCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s', $currentParts[0] + 1));
|
||||
$minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue