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 3cde3e2..ded5f8f 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::__construct
         * @covers ComposerJson::getRequiredDependencies
diff --git a/tests/phpunit/includes/libs/composer/ComposerLockTest.php 
b/tests/phpunit/includes/libs/composer/ComposerLockTest.php
index 3d5e8d3..eef7e27 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->assertEquals( 'a3bb80b0ac4c4a31e52574d48c032923', 
$lock->getHash() );
-       }
-
-       /**
         * @covers ComposerLock::__construct
         * @covers ComposerLock::getInstalledDependencies
         */

-- 
To view, visit https://gerrit.wikimedia.org/r/316243
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2f22a82699e2b707b6ccb355605999a183a56a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to