Skip to content

Commit

Permalink
Support extjs version format, eg. 4.2.1-883
Browse files Browse the repository at this point in the history
  • Loading branch information
nsams committed Mar 26, 2015
1 parent c70e00d commit 9af61d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Kwf/ComposerExtraAssets/VersionMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ public static function matchVersions($version1, $version2)
return $version1;
}

$v1 = self::_normalizeVersion($version1);
$v2 = self::_normalizeVersion($version2);

try {
$v1 = Constraint::parse($version1);
$v2 = Constraint::parse($version2);
$v1 = Constraint::parse($v1);
$v2 = Constraint::parse($v2);
} catch (\UnexpectedValueException $e) {
return false;
}
Expand All @@ -39,4 +42,11 @@ public static function matchVersions($version1, $version2)
return false;
}
}
private static function _normalizeVersion($v)
{
if (preg_match('#^(\d+\.\d+\.\d+)-(\d+)$#', $v, $m)) {
$v = $m[1].'.'.$m[2];
}
return $v;
}
}
1 change: 1 addition & 0 deletions tests/VersionMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function versions()
array('*', '*', '*'),
array('foo/foo#master', 'foo/foo#master', 'foo/foo#master'),
array(false, '1.0', 'foo/foo#master'),
array('4.2.1-883', '4.2.1-883', '4.2.*'),
);
}

Expand Down

0 comments on commit 9af61d9

Please sign in to comment.