Skip to content
Snippets Groups Projects

Issue #3265874: Do not allow apply if active and staged composer locks are identical.

4 files
+ 13
18
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -60,13 +60,13 @@ class LockFileValidator implements PreOperationStageValidatorInterface {
* Returns the current hash of the given directory's lock file.
*
* @param string $directory
* Directory for composer lock file.
* Path of a directory containing a composer.lock file.
*
* @return string|false
* The hash of the given directory's lock file, or FALSE if the lock file
* does not exist.
*/
protected function getHash(string $directory) {
protected function getLockFileHash(string $directory) {
$file = $directory . DIRECTORY_SEPARATOR . 'composer.lock';
// We want to directly hash the lock file itself, rather than look at its
// content-hash value, which is actually a hash of the relevant parts of
@@ -84,7 +84,7 @@ class LockFileValidator implements PreOperationStageValidatorInterface {
* Stores the current lock file hash.
*/
public function storeHash(PreCreateEvent $event): void {
$hash = $this->getHash($this->pathLocator->getProjectRoot());
$hash = $this->getLockFileHash($this->pathLocator->getProjectRoot());
if ($hash) {
$this->state->set(static::STATE_KEY, $hash);
}
@@ -100,7 +100,7 @@ class LockFileValidator implements PreOperationStageValidatorInterface {
*/
public function validateStagePreOperation(PreOperationStageEvent $event): void {
// Ensure we can get a current hash of the lock file.
$active_hash = $this->getHash($this->pathLocator->getProjectRoot());
$active_hash = $this->getLockFileHash($this->pathLocator->getProjectRoot());
if (empty($active_hash)) {
$error = $this->t('Could not hash the active lock file.');
}
@@ -116,8 +116,8 @@ class LockFileValidator implements PreOperationStageValidatorInterface {
$error = $this->t('Stored lock file hash does not match the active lock file.');
}
if (!isset($error) && $event instanceof PreApplyEvent) {
$stage_hash = $this->getHash($event->getStage()->getStageDirectory());
if (empty($error) && $event instanceof PreApplyEvent) {
$stage_hash = $this->getLockFileHash($event->getStage()->getStageDirectory());
if ($active_hash === $stage_hash) {
$error = $this->t('There are no pending Composer operations.');
}
Loading