Skip to content

chore: cleanup redundant .gitattributes files#8007

Open
pearigee wants to merge 3 commits intomainfrom
pearigee-gitattributes-cleanup
Open

chore: cleanup redundant .gitattributes files#8007
pearigee wants to merge 3 commits intomainfrom
pearigee-gitattributes-cleanup

Conversation

@pearigee
Copy link
Copy Markdown
Contributor

@pearigee pearigee commented Apr 9, 2026

Per googleapis/librarian#4582, our .gitattributes files don't need to defined on a per-package level.

Analyzing all of the .gitattributes files, they appear to fall into two main catagories:

1. Package-level .gitattributes

Almost every package in the repository (both in packages/ and handwritten/) contains an identical .gitattributes file with the following content:

*.ts text eol=lf
*.js text eol=lf
protos/* linguist-generated
**/api-extractor.json  linguist-language=JSON-with-Comments

Note: A few files (like packages/google-cloud-tasks/.gitattributes) appeared to have 3 lines instead of 4, but this was simply due to a missing trailing newline; the content was the same.

2. .kokoro directory .gitattributes

Files located in .kokoro directories generally contain just one line:

* linguist-generated=true

This marks all files within the .kokoro directory as "generated" so they are ignored in GitHub language statistics and diffs.

Consolidating these into a single .gitattributes file

It seems the important bits are simply this:

# Enforce LF line endings for all TS and JS files across the repo
*.ts text eol=lf
*.js text eol=lf

Optionally, we could include the Linguist specific changes (impacting GitHubs code statistics/diffs) but I don't think its strictly necessary. For now, I have opted to ignore them.

# Mark all protos directories as generated for Linguist (removing them from language stats and diffs)
**/protos/* linguist-generated

# Set language for api-extractor.json files
**/api-extractor.json linguist-language=JSON-with-Comments

# Mark all .kokoro directories as generated (removing them from language stats and diffs)
**/.kokoro/** linguist-generated

Generator updates (going to be a separate PR to reduce toil)

I am going to update the generator, to prevent the automatic generation of .gitattributes files, in a second PR since the change is a bit more involved and doesn't require such broad set of reviewers.

@pearigee pearigee requested review from a team as code owners April 9, 2026 23:28
@pearigee pearigee marked this pull request as draft April 9, 2026 23:28
@pearigee pearigee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 9, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 9, 2026
@pearigee pearigee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 9, 2026
@pearigee pearigee marked this pull request as ready for review April 9, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kokoro:force-run Add this label to force Kokoro to re-run the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants