Skip to content

Add missing .gitattributes files for various generated files

Administrator requested to merge vg/add-gitattributes into main

Created by: varungandhi-src

With PR review, I've noticed myself making the mistake multiple times where I end up reading a bunch of generated code when I should be focusing on the original code from which it was generated. Part of the issue here is that GitHub doesn't show the file header, which usually carries a "DO NOT EDIT, this was generated by blah." This problem can be mitigated by using .gitattributes files.

Use a .gitattributes file to mark files that match a given "pattern" with the specified attributes.

Use the linguist-generated attribute to mark or unmark paths that you would like to be ignored for the repository's language statistics and hidden by default in diffs

We already have one at the project root, but that doesn't catch everything. The current patch adds directory-local files, which should be allowed according the Git docs:

When deciding what attributes are assigned to a path, Git consults $GIT_DIR/info/attributes file (which has the highest precedence), .gitattributes file in the same directory as the path in question (emphasis added), and its parent directories up to the toplevel of the work tree (the further the directory that contains .gitattributes is from the path in question, the lower its precedence). Finally global and system-wide files are considered (they have the lowest precedence).

The official GitHub docs recommend:

Unless the .gitattributes file already exists, create a .gitattributes file in the root of the repository.

I'm not 100% sure if directory-local .gitattributes work or not on GitHub. If this patch doesn't work, I guess we can combine all the .gitattributes into one jumbo .gitattributes at the root of the repo.

Merge request reports

Loading