[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: checkComposerLockUpToDate: Always check dependencies
jenkins-bot has submitted this change and it was merged. Change subject: checkComposerLockUpToDate: Always check dependencies .. checkComposerLockUpToDate: Always check dependencies Upstream composer has replaced the 'hash' with a smarter 'content-hash', but instead of re-implementing (or copy-pasting) all of that in MediaWiki we can just compare the dependencies themselves, since that's all we care about. Bug: T147189 Change-Id: Ic2f22a82699e2b707b6ccb355605999a183a56a0 --- M includes/libs/composer/ComposerJson.php M includes/libs/composer/ComposerLock.php M maintenance/checkComposerLockUpToDate.php M tests/phpunit/includes/libs/composer/ComposerJsonTest.php M tests/phpunit/includes/libs/composer/ComposerLockTest.php 5 files changed, 1 insertion(+), 40 deletions(-) Approvals: Reedy: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/libs/composer/ComposerJson.php b/includes/libs/composer/ComposerJson.php index 311508f..62231a8 100644 --- a/includes/libs/composer/ComposerJson.php +++ b/includes/libs/composer/ComposerJson.php @@ -12,12 +12,7 @@ * @param string $location */ public function __construct( $location ) { - $this->hash = md5_file( $location ); $this->contents = json_decode( file_get_contents( $location ), true ); - } - - public function getHash() { - return $this->hash; } /** diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index e93127c..818ccdf 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -15,10 +15,6 @@ $this->contents = json_decode( file_get_contents( $location ), true ); } - public function getHash() { - return $this->contents['hash']; - } - /** * Dependencies currently installed according to composer.lock * diff --git a/maintenance/checkComposerLockUpToDate.php b/maintenance/checkComposerLockUpToDate.php index 9ec61dc..3f0a83d 100644 --- a/maintenance/checkComposerLockUpToDate.php +++ b/maintenance/checkComposerLockUpToDate.php @@ -34,11 +34,7 @@ $lock = new ComposerLock( $lockLocation ); $json = new ComposerJson( $jsonLocation ); - if ( $lock->getHash() === $json->getHash() ) { - $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); - return; - } - // Out of date, lets figure out which dependencies are old + // Check all the dependencies to see if any are old $found = false; $installed = $lock->getInstalledDependencies(); foreach ( $json->getRequiredDependencies() as $name => $version ) { @@ -61,8 +57,6 @@ 1 ); } else { - // The hash is the entire composer.json file, - // so it can be updated without any of the dependencies changing // We couldn't find any out-of-date dependencies, so assume everything is ok! $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); } diff --git a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php index 2072752..4c0f99f 100644 --- a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php @@ -11,22 +11,6 @@ $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json"; } - public static function provideGetHash() { - return [ - [ 'json', 'cc6e7fc565b246cb30b0cac103a2b31e' ], - [ 'json2', '19921dd1fc457f1b00561da932432001' ], - ]; - } - - /** -* @dataProvider provideGetHash -* @covers ComposerJson::getHash -*/ - public function testIsHashUpToDate( $file, $expected ) { - $json = new ComposerJson( $this->$file ); - $this->assertEquals( $expected, $json->getHash() ); - } - /** * @covers ComposerJson::getRequiredDependencies */ diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php index 75eb62c..6097d6d 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -11,14 +11,6 @@ } /** -* @covers ComposerLock::getHash -*/ - public function testGetHash() { - $lock = new ComposerLock( $this->lock ); - $this->
[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: checkComposerLockUpToDate: Always check dependencies
Reedy has uploaded a new change for review. https://gerrit.wikimedia.org/r/316244 Change subject: checkComposerLockUpToDate: Always check dependencies .. checkComposerLockUpToDate: Always check dependencies Upstream composer has replaced the 'hash' with a smarter 'content-hash', but instead of re-implementing (or copy-pasting) all of that in MediaWiki we can just compare the dependencies themselves, since that's all we care about. Bug: T147189 Change-Id: Ic2f22a82699e2b707b6ccb355605999a183a56a0 --- M includes/libs/composer/ComposerJson.php M includes/libs/composer/ComposerLock.php M maintenance/checkComposerLockUpToDate.php M tests/phpunit/includes/libs/composer/ComposerJsonTest.php M tests/phpunit/includes/libs/composer/ComposerLockTest.php 5 files changed, 1 insertion(+), 40 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/44/316244/1 diff --git a/includes/libs/composer/ComposerJson.php b/includes/libs/composer/ComposerJson.php index 311508f..62231a8 100644 --- a/includes/libs/composer/ComposerJson.php +++ b/includes/libs/composer/ComposerJson.php @@ -12,12 +12,7 @@ * @param string $location */ public function __construct( $location ) { - $this->hash = md5_file( $location ); $this->contents = json_decode( file_get_contents( $location ), true ); - } - - public function getHash() { - return $this->hash; } /** diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index e93127c..818ccdf 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -15,10 +15,6 @@ $this->contents = json_decode( file_get_contents( $location ), true ); } - public function getHash() { - return $this->contents['hash']; - } - /** * Dependencies currently installed according to composer.lock * diff --git a/maintenance/checkComposerLockUpToDate.php b/maintenance/checkComposerLockUpToDate.php index 9ec61dc..3f0a83d 100644 --- a/maintenance/checkComposerLockUpToDate.php +++ b/maintenance/checkComposerLockUpToDate.php @@ -34,11 +34,7 @@ $lock = new ComposerLock( $lockLocation ); $json = new ComposerJson( $jsonLocation ); - if ( $lock->getHash() === $json->getHash() ) { - $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); - return; - } - // Out of date, lets figure out which dependencies are old + // Check all the dependencies to see if any are old $found = false; $installed = $lock->getInstalledDependencies(); foreach ( $json->getRequiredDependencies() as $name => $version ) { @@ -61,8 +57,6 @@ 1 ); } else { - // The hash is the entire composer.json file, - // so it can be updated without any of the dependencies changing // We couldn't find any out-of-date dependencies, so assume everything is ok! $this->output( "Your composer.lock file is up to date with current dependencies!\n" ); } diff --git a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php index 2072752..4c0f99f 100644 --- a/tests/phpunit/includes/libs/composer/ComposerJsonTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerJsonTest.php @@ -11,22 +11,6 @@ $this->json2 = "$IP/tests/phpunit/data/composer/new-composer.json"; } - public static function provideGetHash() { - return [ - [ 'json', 'cc6e7fc565b246cb30b0cac103a2b31e' ], - [ 'json2', '19921dd1fc457f1b00561da932432001' ], - ]; - } - - /** -* @dataProvider provideGetHash -* @covers ComposerJson::getHash -*/ - public function testIsHashUpToDate( $file, $expected ) { - $json = new ComposerJson( $this->$file ); - $this->assertEquals( $expected, $json->getHash() ); - } - /** * @covers ComposerJson::getRequiredDependencies */ diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php b/tests/phpunit/includes/libs/composer/ComposerLockTest.php index 75eb62c..6097d6d 100644 --- a/tests/phpunit/includes/libs/composer/ComposerLockTest.php +++ b/tests/phpunit/includes/libs/composer/ComposerLockTest.php @@ -11,14 +11,6 @@ } /** -* @covers ComposerLock::getHash -*/ - public function testGetHash() { - $lock = new ComposerLock