josh icon indicating copy to clipboard operation
josh copied to clipboard

.gitattributes with macros in workspace subfolder

Open benblo opened this issue 9 months ago • 0 comments

I have a monorepo where each workspace has a .gitattributes in its own subfolder:

monorepo:

  • shared/
  • workspaces/A/
    • .gitattributes
    • contentA/
  • workspaces/B/
    • .gitattributes
    • contentB/

becomes workspace-A:

  • .gitattributes
  • contentA/
  • shared/

Problem: those gitattributes files define custom macros, which are only allowed in top-level gitattributes files, so in the main monorepo, I'm getting warnings like this:

[attr]unity_yaml -text merge=unityyamlmerge diff eol=lf not allowed: Workspace/Cartographer/.gitattributes:54

One workaround I can think of is to rename those to eg josh.gitattributes in the main repo, then rename them back in the filter. It feels icky though, those attributes wouldn't then be processed at the monorepo level.

Another idea would be to define the macros in a separate file, sitting at the root (it would make sense to share the macros anyway, though I can imagine there would be exceptions down the line), then somehow reference those in the per-workspace gitattributes... I don't know how to do that though 😅.

Has anyone run into this? Ideas?

benblo avatar May 24 '24 09:05 benblo