From 0039c527cbdd461ccf9d21f52e054ff3053cb281 Mon Sep 17 00:00:00 2001 From: Lee Rowlands Date: Mon, 19 Aug 2019 14:27:23 +1000 Subject: [PATCH] Issue #3075621 by greg.1.anderson: Scaffold plugin sometimes fails to write autoload.php --- .../Component/Scaffold/GenerateAutoloadReferenceFile.php | 7 ++++--- .../Component/Scaffold/Functional/ManageGitIgnoreTest.php | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Component/Scaffold/GenerateAutoloadReferenceFile.php b/core/lib/Drupal/Component/Scaffold/GenerateAutoloadReferenceFile.php index 30d2ce1d363c..214163ab0934 100644 --- a/core/lib/Drupal/Component/Scaffold/GenerateAutoloadReferenceFile.php +++ b/core/lib/Drupal/Component/Scaffold/GenerateAutoloadReferenceFile.php @@ -62,11 +62,12 @@ final class GenerateAutoloadReferenceFile { */ public static function autoloadFileCommitted(IOInterface $io, $package_name, $web_root) { $autoload_path = static::autoloadPath($package_name, $web_root); - $location = dirname($autoload_path->fullPath()); - if (!file_exists($location)) { + $autoload_file = $autoload_path->fullPath(); + $location = dirname($autoload_file); + if (!file_exists($autoload_file)) { return FALSE; } - return Git::checkTracked($io, $location, $location); + return Git::checkTracked($io, $autoload_file, $location); } /** diff --git a/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php b/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php index ed79869f66e2..9556868e2ad5 100644 --- a/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php +++ b/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php @@ -104,10 +104,12 @@ class ManageGitIgnoreTest extends TestCase { // Note that the drupal-composer-drupal-project fixture does not // have any configuration settings related to .gitignore management. $sut = $this->createSutWithGit('drupal-composer-drupal-project'); + $this->assertFileNotExists($sut . '/docroot/autoload.php'); $this->assertFileNotExists($sut . '/docroot/index.php'); $this->assertFileNotExists($sut . '/docroot/sites/.gitignore'); // Run the scaffold command. $this->fixtures->runScaffold($sut); + $this->assertFileExists($sut . '/docroot/autoload.php'); $this->assertFileExists($sut . '/docroot/index.php'); $expected = <<createSutWithGit('drupal-drupal'); + $this->assertFileNotExists($sut . '/docroot/autoload.php'); $this->assertFileNotExists($sut . '/docroot/index.php'); // Run the scaffold command. $this->fixtures->runScaffold($sut); + $this->assertFileExists($sut . '/autoload.php'); $this->assertFileExists($sut . '/index.php'); $this->assertFileNotExists($sut . '/.gitignore'); $this->assertFileNotExists($sut . '/docroot/sites/default/.gitignore');