Skip to content

Conversation

@JJWRoeloffs
Copy link

@JJWRoeloffs JJWRoeloffs commented Nov 10, 2025

I noticed tokei does not support the linguist-vendorred, linguist-documenttaion, and linguist-generated marks you can put in your .gitattributes while working on a project of mine, and then found that the issue for this was listed as open and help-wanted (#386), (even a few years later). With this pull request, I attempted to implement this linguist support in the way outlined in the original issue.

I haven't programmed in Rust in a while, so I am a bit... rusty (pun absolutely intended.) I hope I did everything properly! ^.^


In this pull request I am:

  • Adding the gix-attributes dependency for .gitattributes parsing, as specified in the original issue.
  • Marking all things with linguist-vendorred, linguist-documenttaion, and linguist-generated in .gitattributes to-ignore using overrides.
    • Adding a test that makes sure this works.
  • Adding a new commandline option --no-ignore-linguist and its documentation, which disables the functionality I added.

EDIT: Coming back a day later, I realize there are some complications that I missed: If you pass multiple directories to tokei, the expected behavior is that each of these directories has its own ignore files that apply locally to the files in those directories, which is indeed how the .gitignore is implemented in the ignore crate. However, with how I implemented gitattributes, any found rule in a gitattribute file applies globally to the entire run, even to separately passed directories. I am expecting there to be a decent fix for this, but I'll wait for your comment before putting more time into this PR.
(It also appears I flipped the ignore parent flag.)

And fix the problem in my code that I found that way, `linguist-ignore`
is a variable that should be true when we _do_ want to use the ignore
from the linguist marks in the .gitattributes file
@XAMPPRocky
Copy link
Owner

Thank you for your PR!

I am expecting there to be a decent fix for this, but I'll wait for your comment before putting more time into this PR.
(It also appears I flipped the ignore parent flag.)

I would expect it to behave the same as ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants