From 2853cf08ff046337b9fa5c2fc9aa6b14bd34d0ec Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 2 Oct 2024 05:39:54 -0700
Subject: [PATCH] Issue #3456699 by nicoschi, joelpittet, doxigo: The dotfiles
 are ignored when copied over in Starterkit

---
 core/lib/Drupal/Core/Command/GenerateTheme.php |  1 +
 .../BuildTests/Command/GenerateThemeTest.php   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/core/lib/Drupal/Core/Command/GenerateTheme.php b/core/lib/Drupal/Core/Command/GenerateTheme.php
index 89540768d28d..ed61dcfdd8e4 100644
--- a/core/lib/Drupal/Core/Command/GenerateTheme.php
+++ b/core/lib/Drupal/Core/Command/GenerateTheme.php
@@ -133,6 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
     $mirror_iterator = (new Finder)
       ->in($starterkit->getPath())
       ->files()
+      ->ignoreDotFiles(FALSE)
       ->notName($starterkit_config['ignore'])
       ->notPath($starterkit_config['ignore']);
 
diff --git a/core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php b/core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php
index 3a2eeb13d551..339eb2b520b6 100644
--- a/core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php
+++ b/core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php
@@ -582,6 +582,24 @@ public function testInfoOverrides(): void {
     self::assertEquals(['core/jquery'], $info['libraries']);
   }
 
+  public function testIncludeDotFiles(): void {
+    file_put_contents($this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/.gitignore', '*.map');
+    $tester = $this->runCommand(
+      [
+        'machine-name' => 'test_custom_theme',
+        '--name' => 'Test custom starterkit theme',
+        '--description' => 'Custom theme generated from a starterkit theme',
+      ]
+    );
+
+    $tester->assertCommandIsSuccessful($tester->getErrorOutput());
+    $this->assertThemeExists('themes/test_custom_theme');
+
+    // Verify that the .gitignore file is present in the generated theme.
+    $theme_path_absolute = $this->getWorkspaceDirectory() . '/themes/test_custom_theme';
+    self::assertFileExists($theme_path_absolute . '/.gitignore');
+  }
+
   private function writeStarterkitConfig(array $config): void {
     $starterkit_yml = $this->getWorkspaceDirectory() . '/core/themes/starterkit_theme/starterkit_theme.starterkit.yml';
     $starterkit_config = Yaml::decode(file_get_contents($starterkit_yml));
-- 
GitLab