From bf53470bd66cc7472448a9bb3fa2ca842e71fb73 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 25 Dec 2021 05:26:54 +0100 Subject: [PATCH] Bug fix: don't error out on out-of-sync lock file As far as I can see, the `--no-check-lock` argument has been available since Composer 1.0, so adding this argument to the `composer validate` command should be safe and should prevent the issues as reported in 206. Includes tests (though the test isn't running properly yet). Fixes 206 --- bin/composer_paths.sh | 1 + tests/expect/composer_paths_08.exp | 17 +++++++++++++++ tests/fixtures/out-of-sync-lock/composer.json | 16 ++++++++++++++ tests/fixtures/out-of-sync-lock/composer.lock | 21 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100755 tests/expect/composer_paths_08.exp create mode 100644 tests/fixtures/out-of-sync-lock/composer.json create mode 100644 tests/fixtures/out-of-sync-lock/composer.lock diff --git a/bin/composer_paths.sh b/bin/composer_paths.sh index 67543cd..1dca4b7 100755 --- a/bin/composer_paths.sh +++ b/bin/composer_paths.sh @@ -12,6 +12,7 @@ function validate_composer { "${php_path}" "${composer_path}" \ validate \ --no-check-publish \ + --no-check-lock \ --working-dir "${working_directory}" \ > /dev/null 2>&1 } diff --git a/tests/expect/composer_paths_08.exp b/tests/expect/composer_paths_08.exp new file mode 100755 index 0000000..7e96005 --- /dev/null +++ b/tests/expect/composer_paths_08.exp @@ -0,0 +1,17 @@ +#!/usr/bin/env -S expect -f + +set timeout 3 +spawn ../../bin/composer_paths.sh "" "../fixtures/out-of-sync-lock" +match_max 100000 + +expect "::debug::Composer path is '*'\r +::debug::Composer version *\r +::debug::Composer cache directory found at '*'\r +::debug::File composer.json found at '../fixtures/out-of-sync-lock/composer.json'\r +::debug::File composer.lock path computed as '../fixtures/out-of-sync-lock/composer.lock'\r +::set-output name=command::*\r +::set-output name=cache-dir::*\r +::set-output name=json::../fixtures/out-of-sync-lock/composer.json\r +::set-output name=lock::../fixtures/out-of-sync-lock/composer.lock\r +" +expect eof diff --git a/tests/fixtures/out-of-sync-lock/composer.json b/tests/fixtures/out-of-sync-lock/composer.json new file mode 100644 index 0000000..f5a3a61 --- /dev/null +++ b/tests/fixtures/out-of-sync-lock/composer.json @@ -0,0 +1,16 @@ +{ + "name": "ramsey/composer-install-test-out-of-sync-lock", + "description": "Tests composer-install when composer.lock file is out of sync.", + "license": "MIT", + "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com" + } + ], + "config": { + "platform": { + + } + } +} diff --git a/tests/fixtures/out-of-sync-lock/composer.lock b/tests/fixtures/out-of-sync-lock/composer.lock new file mode 100644 index 0000000..68202d6 --- /dev/null +++ b/tests/fixtures/out-of-sync-lock/composer.lock @@ -0,0 +1,21 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "32d8479198ae031d96dd19b4332b8b0a", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "platform-overrides": { + "php": "5.6.40" + }, + "plugin-api-version": "2.2.0" +}