Add prettyVersion to URL placeholders
parent
c257395a6d
commit
93a5b27631
|
@ -625,14 +625,14 @@ class Package extends BasePackage
|
|||
}
|
||||
|
||||
if ($urlType === 'dist' && false !== strpos($url, '%')) {
|
||||
$url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type);
|
||||
$url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
|
||||
}
|
||||
|
||||
$urls = array($url);
|
||||
if ($mirrors) {
|
||||
foreach ($mirrors as $mirror) {
|
||||
if ($urlType === 'dist') {
|
||||
$mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
|
||||
$mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
|
||||
} elseif ($urlType === 'source' && $type === 'git') {
|
||||
$mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
|
||||
} elseif ($urlType === 'source' && $type === 'hg') {
|
||||
|
|
|
@ -19,18 +19,21 @@ namespace Composer\Util;
|
|||
*/
|
||||
class ComposerMirror
|
||||
{
|
||||
public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
|
||||
public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null)
|
||||
{
|
||||
if ($reference) {
|
||||
$reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
|
||||
}
|
||||
$version = strpos($version, '/') === false ? $version : md5($version);
|
||||
|
||||
return str_replace(
|
||||
array('%package%', '%version%', '%reference%', '%type%'),
|
||||
array($packageName, $version, $reference, $type),
|
||||
$mirrorUrl
|
||||
);
|
||||
$from = array('%package%', '%version%', '%reference%', '%type%');
|
||||
$to = array($packageName, $version, $reference, $type);
|
||||
if (null !== $prettyVersion) {
|
||||
$from[] = '%prettyVersion%';
|
||||
$to[] = $prettyVersion;
|
||||
}
|
||||
|
||||
return str_replace($from, $to, $mirrorUrl);
|
||||
}
|
||||
|
||||
public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
|
||||
|
|
Loading…
Reference in New Issue