ddev-drupal-contrib
ddev-drupal-contrib copied to clipboard
How to have a contrib module with a .gitattributes file?
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.
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.
Lets go with scaffolding config as the recommended solution here.
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"
}
}
}
}