From 30942b2d952efa4187d66b54ebd64c7820f80cd4 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 4 Feb 2024 23:43:42 +0000 Subject: [PATCH] git: allow for creating inclusive gitignore files --- src/DataTransferObject/ConfigDto.php | 4 ++++ templates/drupal/.gitignore.twig | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DataTransferObject/ConfigDto.php b/src/DataTransferObject/ConfigDto.php index 2384ee4..91f562f 100644 --- a/src/DataTransferObject/ConfigDto.php +++ b/src/DataTransferObject/ConfigDto.php @@ -116,6 +116,10 @@ final class ConfigDto new Assert\Type('bool'), ]), + 'createInclusiveGitIgnoreFile' => new Assert\Optional([ + new Assert\Type('bool'), + ]), + 'createTmuxStartupFile' => new Assert\Optional([ new Assert\Type('bool'), ]), diff --git a/templates/drupal/.gitignore.twig b/templates/drupal/.gitignore.twig index d9edb98..087c7f0 100644 --- a/templates/drupal/.gitignore.twig +++ b/templates/drupal/.gitignore.twig @@ -1,5 +1,6 @@ # {{ managedText|raw }} +{% if not experimental.createInclusiveGitIgnoreFile %} .editorconfig .env .gitattributes @@ -44,7 +45,19 @@ docker-compose.override.yaml {% if flake is defined %} .dir-env/ {% endif %} +{% else %} +# Ignore everything. +* -{% for path in git.ignore %} +# Include these things: +!/{{ drupal.docroot }}/*/custom/** +{% endif %} + +{% for path in git.ignore|sort %} {{ path }} {% endfor %} + +{% if experimental.createInclusiveGitIgnoreFile %} +# Even if they are in sub-directories. +!*/ +{% endif %}