From 407ec4fba2b0d2714e065f0d356542272a506d6c Mon Sep 17 00:00:00 2001 From: Colby Mchenry Date: Fri, 30 Oct 2026 06:14:08 +0000 Subject: [PATCH] chore: keep the kernel's vendored grammars out of GitHub's language stats (#3045) GitHub reports the repository as 79% C and 18% TypeScript. Nearly all of that C is the third-party tree-sitter grammars the native kernel compiles from source (codegraph-kernel/grammars/, 29 files, about 78 MB). A new .gitattributes marks every file under codegraph-kernel/grammars/ linguist-vendored, so Linguist leaves them out of the language statistics, and marks the five generated parser.c files linguist-generated, so pull requests show those collapsed. The hand-written scanner.c files stay expanded in diffs on purpose: that is where C gets patched or added (PR 2173, and the open PR 2866), and every contributor PR is security-reviewed, so such a change must stay visible. The patterns use /** because an attributes pattern that names a directory does not reach the files inside it. Validation: git check-attr over all 1,722 tracked files reports linguist-vendored set on exactly the 29 files under codegraph-kernel/grammars/ and linguist-generated set on exactly the five parser.c files; scanner.c, the headers and the LICENSE files are vendored only, and everything else, src/index.ts included, has neither. In a scratch repository the bare directory pattern leaves parser.c unspecified. Git does not act on linguist attributes and codegraph never reads .gitattributes, so builds and tests are unaffected. Raised by PR 2513 (@build8421) and PR 1668 (@kidonng). Co-Authored-By: Claude Opus 5.5 --- .gitattributes | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..a63fc54f5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# Third-party tree-sitter grammars that the native kernel compiles from source +# (codegraph-kernel/build.rs). Keep all of them out of GitHub's language +# statistics, and collapse only the generated parser.c files in pull-request +# diffs. The hand-written scanner.c files are where C gets patched or added, +# so they stay expanded for review. +# The /** is needed: an attributes pattern that names a directory does not +# reach the files inside it. +codegraph-kernel/grammars/** linguist-vendored +codegraph-kernel/grammars/**/parser.c linguist-generated