ddev-drupal-contrib icon indicating copy to clipboard operation
ddev-drupal-contrib copied to clipboard

How to have a contrib module with a .gitattributes file?

Open chrisfromredfin opened this issue 1 year ago • 1 comments

I would like my contrib module (Project Browser) to have its own .gitattributes file (it needs this to help with git diff's in GitLab since we're committing a compiled file).

When I use ddev-drupal-contrib, though, it seems to clobber the .gitattributes file in the root of my project. I think this is a file being scaffolded by Drupal core dev...?

Also see https://github.com/ddev/ddev-drupal-contrib/issues/25#issuecomment-1954650941 where this was mentioned before, but more as an aside to a different issue.

chrisfromredfin avatar Oct 02 '24 17:10 chrisfromredfin

You might want to edit or add a composer.json file with the proper configuration not to scaffold that file, although maybe this can be added as an addition to the add on without needing to configure that.

hanoii avatar Oct 08 '24 19:10 hanoii

Lets go with scaffolding config as the recommended solution here.

weitzman avatar Nov 21 '24 12:11 weitzman

For anyone coming here wondering exactly how to implement this, add this to you module's composer.json to avoid replacing the .gitattributes file:

    "extra": {
       "drupal-scaffold": {
            "file-mapping": {
                "[project-root]/.gitattributes": {
                    "mode": "skip"
                }
            }
        }
    }

dafeder avatar Oct 30 '25 16:10 dafeder