Merge branch '4.1'
* 4.1: [travis] ignore ordering when validating composer.lock files for deps=low
This commit is contained in:
commit
37a3f0b613
27
.github/rm-invalid-lowest-lock-files.php
vendored
27
.github/rm-invalid-lowest-lock-files.php
vendored
@ -3,7 +3,7 @@
|
|||||||
array_shift($_SERVER['argv']);
|
array_shift($_SERVER['argv']);
|
||||||
$dirs = $_SERVER['argv'];
|
$dirs = $_SERVER['argv'];
|
||||||
|
|
||||||
function getContentHash($composerJson)
|
function getRelevantContent(array $composerJson)
|
||||||
{
|
{
|
||||||
$relevantKeys = array(
|
$relevantKeys = array(
|
||||||
'name',
|
'name',
|
||||||
@ -27,12 +27,18 @@ function getContentHash($composerJson)
|
|||||||
$relevantContent['config']['platform'] = $composerJson['config']['platform'];
|
$relevantContent['config']['platform'] = $composerJson['config']['platform'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $relevantContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContentHash(array $composerJson)
|
||||||
|
{
|
||||||
|
$relevantContent = getRelevantContent($composerJson);
|
||||||
ksort($relevantContent);
|
ksort($relevantContent);
|
||||||
|
|
||||||
return md5(json_encode($relevantContent));
|
return md5(json_encode($relevantContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
$composerLocks = array();
|
$composerJsons = array();
|
||||||
|
|
||||||
foreach ($dirs as $dir) {
|
foreach ($dirs as $dir) {
|
||||||
if (!file_exists($dir.'/composer.lock') || !$composerLock = @json_decode(file_get_contents($dir.'/composer.lock'), true)) {
|
if (!file_exists($dir.'/composer.lock') || !$composerLock = @json_decode(file_get_contents($dir.'/composer.lock'), true)) {
|
||||||
@ -50,28 +56,29 @@ foreach ($dirs as $dir) {
|
|||||||
@unlink($dir.'/composer.lock');
|
@unlink($dir.'/composer.lock');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$composerLocks[$composerJson['name']] = array($dir, $composerLock, $composerJson);
|
$composerJsons[$composerJson['name']] = array($dir, $composerLock['packages'], getRelevantContent($composerJson));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($composerLocks as list($dir, $composerLock)) {
|
foreach ($composerJsons as list($dir, $lockedPackages)) {
|
||||||
foreach ($composerLock['packages'] as $composerJson) {
|
foreach ($lockedPackages as $lockedJson) {
|
||||||
if (0 !== strpos($version = $composerJson['version'], 'dev-') && '-dev' !== substr($version, -4)) {
|
if (0 !== strpos($version = $lockedJson['version'], 'dev-') && '-dev' !== substr($version, -4)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($composerLocks[$name = $composerJson['name']])) {
|
if (!isset($composerJsons[$name = $lockedJson['name']])) {
|
||||||
echo "$dir/composer.lock references missing $name.\n";
|
echo "$dir/composer.lock references missing $name.\n";
|
||||||
@unlink($dir.'/composer.lock');
|
@unlink($dir.'/composer.lock');
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('minimum-stability', 'prefer-stable', 'repositories') as $key) {
|
foreach (array('minimum-stability', 'prefer-stable', 'repositories') as $key) {
|
||||||
if (array_key_exists($key, $composerLocks[$name][2])) {
|
if (array_key_exists($key, $composerJsons[$name][2])) {
|
||||||
$composerJson[$key] = $composerLocks[$name][2][$key];
|
$lockedJson[$key] = $composerJsons[$name][2][$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getContentHash($composerJson) !== $composerLocks[$name][1]['content-hash']) {
|
// use weak comparison to ignore ordering
|
||||||
|
if (getRelevantContent($lockedJson) != $composerJsons[$name][2]) {
|
||||||
echo "$dir/composer.lock is not in sync with $name.\n";
|
echo "$dir/composer.lock is not in sync with $name.\n";
|
||||||
@unlink($dir.'/composer.lock');
|
@unlink($dir.'/composer.lock');
|
||||||
continue 2;
|
continue 2;
|
||||||
|
Reference in New Issue
Block a user